1    def deleteNode(self, item):
2        x = parent = None
3        found = False
4        found, x, parent = self.findForDelete(item, found, x, parent)
5        if found is False:
6            return found
7        if (x.left != None) and (x.right != None):
8            # x has 2 childern, find its successor
9            xSucc = x.right
10           parent = x
11           while xSucc.left is not None: #descend left
12               parent = xSucc
13               xSucc = xSucc.left
14           #Move content of xSucc to x and change x
15           #to point to successor, which be deleted
16           x.key = xSucc.key 
17           x = xSucc
18       #end of if
19       subtree = x.left
20       if subtree == None:
21           subtree = x.right
22       if parent == None:    #root being deleted
23           self.root = subtree
24       elif parent.left == x: #left child of parent
25           parent.left = subtree
26       else:    #right child
27           parent.right = subtree
28       del x
29        return found