first functioning (naive) union_find