Naive way of union find.