Converted DisjointSet to be genereic