input: Write a python function to decode a tree from its string representation.
  assert decode("1(2(None, None), 3(None, None))") == TreeNode(1, TreeNode(2), TreeNode(3))
  assert decode("1(2(4(None, None), 5(None, None)), 3(None, 6(None, None)))") == TreeNode(1, TreeNode(2, TreeNode(4), TreeNode(5)), TreeNode(3, None, TreeNode(6)))
  assert decode("None") == None
output: def decode(s):
      def helper(tokens):
          if tokens[0] == 'None':
              tokens.pop(0)
              return None
          val = int(tokens.pop(0))
          tokens.pop(0)  # remove '('
          left = helper(tokens)
          tokens.pop(0)  # remove ','
          right = helper(tokens)
          tokens.pop(0)  # remove ')'
          return TreeNode(val, left, right)
  
      tokens = []
      i = 0
      while i < len(s):
          if s[i] in '(),':
              tokens.append(s[i])
              i += 1
          elif s[i].isdigit() or s[i] == 'N':
              j = i
              while j < len(s) and (s[j].isdigit() or s[j] in 'None'):
                  j += 1
              tokens.append(s[i:j])
              i = j
      return helper(tokens)