# class TreeNode:
#     def __init__(self, x):
#         self.val = x
#         self.left = None
#         self.right = None

#
# 
# @param root TreeNode类 
# @param sum int整型 
# @return int整型二维数组
#
import copy
class Solution:
    total = 0
    li = []
    tmpLi = []
    def pathSum(self , root , sum ):
        # write code here
        if root:
            self.preOrders(root, sum)
        return self.li
    def preOrders(self, root, sum):
        sum -= root.val
        self.tmpLi.append(root.val)
        ret = False
        if root.left is None and root.right is None:
            ret = sum == 0
        else:
            if root.left:
                self.preOrders(root.left, sum)
            if root.right:
                self.preOrders(root.right, sum)
        if ret:
            self.li.append(copy.copy(self.tmpLi))
        self.tmpLi.pop()
        return ret