internal/functions/Merge-ExportNodeAncestors.ps1

function Merge-ExportNodeAncestors {
    [CmdletBinding()]
    param (
        [hashtable] $ParentNode,
        [string] $PacSelector,
        [string] $PropertyName,
        $PropertyValue
    )

    $parentClusters = $ParentNode.clusters
    if (-not $parentClusters.ContainsKey($PropertyName)) {
        $null = $parentClusters.Add($PropertyName, (ConvertTo-ArrayList $PropertyValue))
        $ParentNode[$PropertyName] = $PropertyValue
    }
    else {
        $parentCluster = $parentClusters.$PropertyName
        foreach ($clusterItem in $parentCluster) {
            $match = Confirm-ObjectValueEqualityDeep $clusterItem $PropertyValue
            if ($match) {
                return $true
            }
        }
        $null = $parentCluster.Add($PropertyValue)
        if ($ParentNode.ContainsKey($PropertyName)) {
            $null = $ParentNode.Remove($PropertyName)
        }
    }
    return $false
}