class Solution(object):
def hasPathSum(self, root, sumt):
"""
:type root: TreeNode
:type sumt: int
:rtype: bool
"""
if not root and sum:
return False
stack = [(root, [root.val])]
while stack:
node, temp = stack.pop()
if not node.left and not node.right and sum(temp) == sumt:
return True
if node.left:
stack.append((node.left, temp + [node.left.val]))
if node.right:
stack.append((node.right, temp + [node.right.val]))
return False