if node is leaf and sum is found greater than data than remove node An important thing to remember is that a non - leaf node can become a leaf when its children are removed
if root . left is None and root . right is None : NEW_LINE INDENT if sum > root . data : NEW_LINE INDENT return None NEW_LINE DEDENT DEDENT return root NEW_LINE