figure deleting node node with two children we simply put it in the tree in place of the node to be deleted the code to handle the third case is shown below notice that we make use of the helper methods find_successor and find_min to find the successor to remove the successorwe make use of the method splice_out the reason we use splice_out is that it goes directly to the node we want to splice out and makes the right changes we could call delete recursivelybut then we would waste time re-searching for the key node elif current_node has_both_children()#interior succ current_node find_successor(succ splice_out(current_node key succ key current_node payload succ payload the code to find the successor is shown below and as you can see is method of the treenode class this code makes use of the same properties of binary search trees that cause an inorder traversal to print out the nodes in the tree from smallest to largest there are three cases to consider when looking for the successor if the node has right childthen the successor is the smallest key in the right subtree if the node has no right child and is the left child of its parentthen the parent is the successor if the node is the right child of its parentand itself has no right childthen the successor to this node is the successor of its parentexcluding this node the first condition is the only one that matters for us when deleting node from binary search tree howeverthe find_successor method has other uses that we will explore in the exercises at the end of this trees and tree algorithms