In theory, after calling make_set(), in which set the parent of each element to itself, the recursion will be ended after at most O(num_element) steps. I am agree to rewrite it with no recursion and add some unit-tests.