elsenext_node node right_child if parentif parent left_child is nodeparent left_child next_node elseparent right_child next_node elseself root_node next_node next_node is used to keep track of where the single node pointed to by the node we want to delete is we then connect parent left_child or parent right_child to next_node lastlywe handle the condition where the node we want to delete has two childrenelseparent_of_leftmost_node node leftmost_node node right_child while leftmost_node left_childparent_of_leftmost_node leftmost_node leftmost_node leftmost_node left_child node data leftmost_node data in finding the in-order successorwe move to the right node with leftmost_node node right_child as long as there exists left nodeleftmost_node left_child will evaluate to true and the while loop will run when we get to the leftmost nodeit will either be leaf node (meaning that it will have no child nodeor have right child we update the node about to be removed with the value of the in-order successor with node data leftmost_node dataif parent_of_leftmost_node left_child =leftmost_nodeparent_of_leftmost_node left_child leftmost_node right_child elseparent_of_leftmost_node right_child leftmost_node right_child the preceding statement allows us to properly attach the parent of the leftmost node with any child node observe how the right-hand side of the equals sign stays unchanged that is because the in-order successor can only have right child as its only child the remove operation takes ( )where is the height of the tree