presto-main/src/main/java/io/prestosql/util/DisjointSet.java/DisjointSet/getEquivalentClasses
class DisjointSet:    public Collection<Set<T>> getEquivalentClasses()
    {
        // map from root element to all element in the tree
        Map<T, Set<T>> rootToTreeElements = new LinkedHashMap<>();
        for (Map.Entry<T, Entry<T>> entry : map.entrySet()) {
            T node = entry.getKey();
            T root = findInternal(node);
            rootToTreeElements.computeIfAbsent(root, unused -> new LinkedHashSet<>());
            rootToTreeElements.get(root).add(node);
        }
        return rootToTreeElements.values();
    }