human
I am working on the file "03_BinaryTree_DivideConquer.ipynb".
The first task is:
Binary Tree Path Sum II

Your are given a binary tree in which each node contains a value. Design an algorithm to get all paths which sum to a given value. The path does not need to start or end at the root or a leaf, but it must go in a straight line down.
http://www.lintcode.com/en/problem/binary-tree-path-sum-ii/
Can you write Python code for it?

Write me a the Python code you requested?
assistant
#Here is the Python code you requested.

"""
Definition of TreeNode:
class TreeNode:
    def __init__(self, val):
        self.val = val
        self.left, self.right = None, None
"""
class Solution:
    # @param {TreeNode} root the root of binary tree
    # @param {int} target an integer
    # @return {int[][]} all valid paths
    def binaryTreePathSum2(self, root, target):
        # Write your code here
        path, result = [], []
        self.dfs(root, path, result, 0, target)
        return result
        
        
        
    def dfs(self, root, path, result, l, target):
        if root is None:
            return 
        path.append(root.val)
        temp = target
        for i in xrange(l, -1, -1):
            temp -= path[i]
            if temp == 0:
                result.append(path[i:])
        
        self.dfs(root.left, path, result, l + 1, target)
        self.dfs(root.right, path, result, l + 1, target)
        
        path.pop()