def delete_node(self, root, key):
if not root: return None<EOL>if root.val == key:<EOL><INDENT>if root.left:<EOL><INDENT>left_right_most = root.left<EOL>while left_right_most.right:<EOL><INDENT>left_right_most = left_right_most.right<EOL><DEDENT>left_right_most.right = root.right<EOL>return root.left<EOL><DEDENT>else:<EOL><INDENT>return root.right<EOL><DEDENT><DEDENT>elif root.val > key:<EOL><INDENT>root.left = self.deleteNode(root.left, key)<EOL><DEDENT>else:<EOL><INDENT>root.right = self.deleteNode(root.right, key)<EOL><DEDENT>return root<EOL>
:type root: TreeNode
:type key: int
:rtype: TreeNode