the only difference is that before we update the current variable inside the loopwe store its parent with parent current the method to do the actual removal of node begins with this searchdef remove(selfdata)parentnode self get_node_with_parent(dataif parent is none and node is nonereturn false get children count children_count if node left_child and node right_childchildren_count elif (node left_child is noneand (node right_child is none)children_count elsechildren_count we pass the parent and the found node to parent and node respectively with the line parentnode self get_node_with_parent(datait is helpful to know the number of children that the node we want to delete has that is the purpose of the if statement after thiswe need to begin handling the various conditions under which node can be deleted the first part of the if statement handles the case where the node has no childrenif children_count = if parentif parent right_child is nodeparent right_child none elseparent left_child none elseself root_node none if parentis used to handle cases where there is bst that has only one node in the whole of the three in the case where the node about to be deleted has only one childthe elif part of the if statement does the followingelif children_count = next_node none if node left_childnext_node node left_child