Kruskal Algorithm: UnionFind optimization