Spoilerclass Solution(object):

```
def recursive_dfs(self,root,sum,paths,path,path_sum):
if root:
path.append(root.val)
path_sum += root.val
if not root.left and not root.right:
if path_sum == sum:
paths.append(list(path))#？？
self.recursive_dfs(root.left,sum,paths,path,path_sum)
self.recursive_dfs(root.right,sum,paths,path,path_sum)
path.pop()
def pathSum(self, root, sum):
paths = []
path = []
self.recursive_dfs(root,sum,paths,path,0)
return paths
```