def METHOD_NAME(self, root, val):  ## driver function for delettion
    if root is None:
        return None
    else:
        if val < root.data:
            root.left = self.METHOD_NAME(root.left, val)
        elif val > root.data:
            root.right = self.METHOD_NAME(root.right, val)
        else:
            if not root.left:
                right = root.right
                del root
                return right
            if not root.right:
                left = root.left
                del root
                return left
            else:
                successor = self.successor(root)
                root.data = successor.data
                root.right = self.METHOD_NAME(root.right, successor.data)
    return root