QuickUnion implementation