private void performDelete(Node z) {
		// create a node pointer y
		Node y;
		// if z has no left or right subtree
		if (z.left == null || z.right == null) {
			// set y to z
			y = z;
		} else {
			// set y as the successor of z
			y = successor(z);
		}

		// create a node pointer x
		Node x;
		// if y has a left subtree
		if (y.left != null) {
			// set x as that subtree
			x = y.left;
		} else {
			//otherwise set x as the right subtree of y
			x = y.right;
		}
		// if x is not null
		if (x != null) {
			// set the parent of x as the parent of y.
			x.parent = y.parent;
		}
		// if the parent of y is null
		if (y.parent == null) {
			// set x as the root
			root = x;
		} else if (y.equals(y.parent.left)) {
			// otherwise if y is the parent of the left subtree of y
			// set it to x
			y.parent.left = x;
		} else {
			// otherwise set the right subtree of the parent of y to x
			y.parent.right = x;
		}

		// if y is not z
		if (y != z) {
			// set the element of z to y
			z.key = y.key;
		}
		// decrease the size by 1
		size--;
	}