private static TreeMap<String, NodeDiff> computeGroupDiff(DistributionConfigBundle oldCfg, DistributionConfigBundle newCfg) {
        var oldGroupNodes = enumerateGroupNodes(oldCfg);
        var newGroupNodes = enumerateGroupNodes(newCfg);

        var unionLeafGroupNames = new HashSet<>(oldGroupNodes.keySet());
        unionLeafGroupNames.addAll(newGroupNodes.keySet());

        var emptySentinel = new GroupNodes(Set.of());
        var diff = new TreeMap<String, NodeDiff>();
        for (String leafName : unionLeafGroupNames) {
            var oldG = oldGroupNodes.getOrDefault(leafName, emptySentinel);
            var newG = newGroupNodes.getOrDefault(leafName, emptySentinel);
            diff.put(leafName, oldG.sortedDiff(newG));
        }
        return diff;
    }
Utility for computing a "minimal" diff between two arbitrary distribution configs.
clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/DistributionDiffCalculator.java