human
Write me a Python program to find the subtree with minimum sum given the following:
I am working on the file "03_BinaryTree_DivideConquer.ipynb".
The first task is:
Minimum/Maximum Subtree

Minimum Subtree

Given a binary tree, find the subtree with minimum sum. Return the root of the subtree.
https://www.lintcode.com/en/problem/minimum-subtree/
Example
Given a binary tree:
 1

/   \
 -5     2
 / \   /  \
0   2 -4  -5 
return the node 1.
Can you write Python program for it?
assistant
#Here is Python program to find the subtree with minimum sum.

"""
Definition of TreeNode:
class TreeNode:
    def __init__(self, val):
        this.val = val
        this.left, this.right = None, None
"""
class Solution:
    # @param {TreeNode} root the root of binary tree
    # @return {TreeNode} the root of the minimum subtree
    def __init__(self):
        self.node = None
        self.minsum = 0x7FFFFFFF
    
    def findSubtree(self, root):
        # Write your code here
        
        def helper(root):
            if not root:
                return 0
            newsum = helper(root.left) + helper(root.right) + root.val
            if newsum < self.minsum:
                self.minsum = newsum
                self.node = root
            return newsum
        
        helper(root)
        return self.node