public int find(int x) {
		checkValidElement(x);
		int root = x; 
		while (root >= 0 && up[root] >= 0) // find element
			root = up[root]; 
		if (x != root) { // if x not a root, do path compression
			int oldParent = up[x]; // prime loop
			while (oldParent != root) { 
				up[x] = root; // point directly at your root; this is the path compression. 
			 	x = oldParent; // go one level up the tree
			 	oldParent = up[x]; 
		 	} 
		}
		return root;
	}