Below is my code.

```
class Solution:
def pathSum(self, root, sum):
paths = []
if root == None:
return []
stack = [(root,[root.val], sum)]
while len(stack):
node, path, lSum = stack.pop()
path.append(node.val)
if node.left == None and node.right == None:
if lSum == node.val:
paths.append(path)
continue
if node.left != None:
stack.append((node.left, path, lSum-node.val))
if node.right != None:
stack.append((node.right, path, lSum-node.val))
# print "len of path :" + str(len(path))
return paths
```