tested and functionnal union-find