'Encodes a tree to a single string.
:type root: TreeNode
:rtype: str'

def serialize(self, root):

    def serializeHelper(node):
        if (not node):
            vals.append('#')
        else:
            vals.append(str(node.val))
            serializeHelper(node.left)
            serializeHelper(node.right)
    vals = []
    serializeHelper(root)
    return '    '.join(vals)
