export UnionFind function