code: def pathSum(self, root, sum):
      """
      :type root: TreeNode
      :type sum: int
      :rtype: List[List[int]]
      """
      res = []
      if root is None:
          return res
      if sum == root.val and root.left is None and root.right is None:
          return [[root.val]]
      # left side
      left_res = self.pathSum(root.left, sum - root.val)
      # right side
      right_res = self.pathSum(root.right, sum - root.val)
      # add current prefix
      for t in left_res + right_res:
          res.append([root.val] + t)
      return res
  
label_desc: Use image node_id 1 for calling the Solution obj's underlying member method code with example usage: obj.pathSum(root, sum) and returns: res, res, list