'XSLT How to delete all duplicated nodes when one field has duplicate values

I am new in XSLT need help, I want to remove all occurrences of A_CustomerCompanyType node when CompanyCode has same duplicate value.

Need help.

Input

<A_CustomerCompany>
    <A_CustomerCompanyType>
        <Customer>1075122</Customer>
        <CompanyCode>1051</CompanyCode>
    </A_CustomerCompanyType>
    <A_CustomerCompanyType>
        <Customer>1075122</Customer>
        <CompanyCode>1081</CompanyCode>
    </A_CustomerCompanyType>
    <A_CustomerCompanyType>
        <Customer>1075123</Customer>
        <CompanyCode>1051</CompanyCode>
    </A_CustomerCompanyType>
    <A_CustomerCompanyType>
        <Customer>1075123</Customer>
        <CompanyCode>3911</CompanyCode>
    </A_CustomerCompanyType>
    <A_CustomerCompanyType>
        <Customer>1075122</Customer>
        <CompanyCode>1041</CompanyCode>
    </A_CustomerCompanyType>
</A_CustomerCompany>

Output

  <A_CustomerCompany>
     <A_CustomerCompanyType>
        <Customer>1075122</Customer>
        <CompanyCode>1081</CompanyCode>
    </A_CustomerCompanyType>
    <A_CustomerCompanyType>
        <Customer>1075123</Customer>
        <CompanyCode>3911</CompanyCode>
    </A_CustomerCompanyType>
    <A_CustomerCompanyType>
        <Customer>1075122</Customer>
        <CompanyCode>1041</CompanyCode>
    </A_CustomerCompanyType>
</A_CustomerCompany>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source