class_docstr: Base class for magic line parsers, designed for forgiving parsing
  of keyword lists.
docstr: Collect the tokens from a (potentially) nested parse result.
docstr_tok: ["Collect","the","tokens","from","a","(","potentially",")","nested","parse","result","."]
code: def collect_tokens(cls, parseresult, mode):
      """
      Collect the tokens from a (potentially) nested parse result.
      """
      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
  
imports: from itertools import groupby
  import numpy
  import param
  import pyparsing
  from ..core.options import Cycle, Options, Palette
  from ..core.util import merge_option_dicts
  from ..operation import Compositor
  from .transform import dim
label_desc: Use image node_id 3 for calling the Parser obj's underlying member method code with example usage: obj.collect_tokens(cls, parseresult, mode) and returns: tokens, list