Simplified the union-find data structure.