figure deleting node node that has single child if current_node has_left_child()if current_node is_left_child()current_node left_child parent current_node parent current_node parent left_child current_node left_child elif current_node is_right_child()current_node left_child parent current_node parent current_node parent right_child current_node left_child elsecurrent_node replace_node_data(current_node left_child keycurrent_node left_child payloadcurrent_node left_child left_childcurrent_node left_child right_childelseif current_node is_left_child()current_node right_child parent current_node parent current_node parent left_child current_node right_child elif current_node is_right_child()current_node right_child parent current_node parent current_node parent right_child current_node right_child elsecurrent_node replace_node_data(current_node right_child keycurrent_node right_child payloadcurrent_node right_child left_childcurrent_node right_child right_childthe third case is the most difficult case to handle if node has two childrenthen it is unlikely that we can simply promote one of them to take the node' place we canhoweversearch the tree for node that can be used to replace the one scheduled for deletion what we need is node that will preserve the binary search tree relationships for both of the existing left and right subtrees the node that will do this is the node that has the next-largest key in the tree we call this node the successorand we will look at way to find the successor shortly the successor is guaranteed to have no more than one childso we know how to remove it using the two cases for deletion that we have already implemented once the successor has been removed binary search trees