optimized quick union with path compression