// RecursiveRemove remove a key from targetNodes recursively.
RecursiveRemove remove a key from targetNodes recursively.
// RecursiveRemove remove a key from targetNodes recursively .
func RecursiveRemove(targetNode *Node, key int) *Node {
	if targetNode == nil {
		return nil
	}
	if key < targetNode.Key {
		targetNode.Left = RecursiveRemove(targetNode.Left, key)
		return targetNode
	}
	if key > targetNode.Key {
		targetNode.Right = RecursiveRemove(targetNode.Right, key)
		return targetNode
	}
	if targetNode.Left == nil && targetNode.Right == nil {
		targetNode = nil
		return nil
	}
	if targetNode.Left == nil {
		targetNode = targetNode.Right
		return targetNode
	}
	if targetNode.Right == nil {
		targetNode = targetNode.Left
		return targetNode
	}
	leftNodeOfMostRightNode := targetNode.Right
	for {
		if leftNodeOfMostRightNode != nil && leftNodeOfMostRightNode.Left != nil {
			leftNodeOfMostRightNode = leftNodeOfMostRightNode.Left
		} else {
			break
		}
	}
	targetNode.Key = leftNodeOfMostRightNode.Key
	targetNode.Right = RecursiveRemove(targetNode.Right, targetNode.Key)
	return targetNode
}
func RecursiveRemove ( targetNode * Node , key int ) * Node { if targetNode == nil { return nil } if key < targetNode . Key { targetNode . Left = RecursiveRemove ( targetNode . Left , key ) return targetNode } if key > targetNode . Key { targetNode . Right = RecursiveRemove ( targetNode . Right , key ) return targetNode } if targetNode . Left == nil && targetNode . Right == nil { targetNode = nil return nil } if targetNode . Left == nil { targetNode = targetNode . Right return targetNode } if targetNode . Right == nil { targetNode = targetNode . Left return targetNode } leftNodeOfMostRightNode := targetNode . Right for { if leftNodeOfMostRightNode != nil && leftNodeOfMostRightNode . Left != nil { leftNodeOfMostRightNode = leftNodeOfMostRightNode . Left } else { break } } targetNode . Key = leftNodeOfMostRightNode . Key targetNode . Right = RecursiveRemove ( targetNode . Right , targetNode . Key ) return targetNode }
RecursiveRemove remove a key from targetNodes recursively.
RecursiveRemove remove a key from targetNodes recursively .