# Definition for a binary tree node.
# class TreeNode(object):
#     def __init__(self, x):
#         self.val = x
#         self.left = None
#         self.right = None

class Solution(object):
    def tree2str(self, t):
        """
        :type t: TreeNode
        :rtype: str
        """
        if not t:
            return ""
        ret = [str(t.val)]
        if t.left or t.right:
            ret.append("(")
            ret.append(self.tree2str(t.left))
            ret.append(")")
            if t.right:
                ret.append("(")
                ret.append(self.tree2str(t.right))
                ret.append(")")
        return ''.join(ret)


Add py solution for 606. Construct String from Binary Tree
Add py solution for 606. Construct String from Binary Tree

606. Construct String from Binary Tree: https://leetcode.com/problems/construct-string-from-binary-tree/
