Union Find graph problem - Search