Finding the subset of the given element is a recursive process that traverses the subset by following the parent elements until the current element is the parent of itself (root element):
public int find(int x) {
if (parent[x] == x) {
return x;
} else {
return find(parent[x]);
}
}