private void _Remove(Node <T, U> currentNode) { //is leaf if (currentNode.IsLeaf()) { //is left child if (currentNode.IsLeftChild()) { currentNode.Parent.LeftChild = null; } //is right child else { currentNode.Parent.RightChild = null; } } //is not leaf else { //is left child if (currentNode.IsLeftChild()) { //has only left child if (currentNode.HasLeftChild() && !currentNode.HasRightChild()) { currentNode.Parent.LeftChild = currentNode.LeftChild; currentNode.LeftChild.Parent = currentNode.Parent; } //has only right child if (!currentNode.HasLeftChild() && currentNode.HasRightChild()) { currentNode.Parent.LeftChild = currentNode.RightChild; currentNode.RightChild.Parent = currentNode.Parent; } //has both children else { } } //is right child else { } } }