Complete Union Find algorithm