Adding implementation of UnionFind