original_docstring: Encodes a tree to a single string.
  
          :type root: Node
          :rtype: str
          
docstring: Encodes a tree to a single string.
docstring_tokens: Encodes a tree to a single string .
code: def serialize(self, root):
          """Encodes a tree to a single string.
  
          :type root: Node
          :rtype: str
          """
          if not root:
              return ''
  
          # Non-recursive
  
          stack = [root]
          parts = []
          while stack:
              curr = stack.pop()
              if curr is None:
                  parts.append('}')
              else:
                  parts.append('%s{' % curr.val)
                  stack.append(None)
                  for child in curr.children[::-1]:
                      stack.append(child)
          return ''.join(parts)
  
          # recursive
  
          # parts = []
          # for child in root.children:
          #     parts.append(self.serialize(child))
          # return '%s{%s}' % (root.val, ''.join(parts))
code_tokens: def serialize ( self , root ) : if not root : return '' stack = [ root ] parts = [ ] while stack : curr = stack . pop ( ) if curr is None : parts . append ( '}' ) else : parts . append ( '%s{' % curr . val ) stack . append ( None ) for child in curr . children [ : : - 1 ] : stack . append ( child ) return '' . join ( parts )
short_docstring: Encodes a tree to a single string.
short_docstring_tokens: Encodes a tree to a single string .
comment: """Encodes a tree to a single string.
  
          :type root: Node
          :rtype: str
          """$SEP$# Non-recursive$SEP$# recursive$SEP$# parts = []$SEP$# for child in root.children:$SEP$#     parts.append(self.serialize(child))$SEP$# return '%s{%s}' % (root.val, ''.join(parts))