code: def collect_tokens(cls, parseresult, mode):
          
          inner = '(%s)' if mode=='parens' else '[%s]'
          if parseresult is None: return []
          tokens = []
          for token in parseresult.asList():
              # If value is a tuple, the token will be a list
              if isinstance(token, list):
                  token = cls.recurse_token(token, inner)
                  tokens[-1] = tokens[-1] + token
              else:
                  if token.strip() == ',': continue
                  tokens.append(cls._strip_commas(token))
          return tokens
docs: Collect the tokens from a (potentially) nested parse result.