For leetcode 112, the question asks you to find if there exists a path from root to leaf that their value add up to targetSum, the solution goes like this:
class Solution(object):
    def hasPathSum(self, root, targetSum):
        """
        :type root: TreeNode
        :type targetSum: int
        :rtype: bool
        """
        
        if not root: return False
        
        if not root.left and not root.right:
            return root.val == targetSum
        
        return self.hasPathSum(root.left, targetSum - root.val) or self.hasPathSum(root.right, targetSum - root.val)
And I can't wrap my head around why the last line inside the function breaks the recursion and returns the final True but if it's False it continues back to the DFS search.
 
     
     
     
    