Generic DisjointSet Implementation