class_docstr: This class serves as an intermediate representation of the
  pattern tree during the conversion to sets of leaf-to-root
  subpatterns
class_docstr_tok: ["This","class","serves","as","an","intermediate","representation","of","the","pattern","tree","during","the","conversion","to","sets","of","leaf-to-root","subpatterns"]
docstr: Internal method. Returns a characteristic path of the
  pattern tree. This method must be run for all leaves until the
  linear subpatterns are merged into a single
docstr_tok: ["Internal","method",".","Returns","a","characteristic","path","of","the","pattern","tree",".","This","method","must","be","run","for","all","leaves","until","the","linear","subpatterns","are","merged","into","a","single"]
code: def leaf_to_root(self):
      """Internal method. Returns a characteristic path of the
      pattern tree. This method must be run for all leaves until the
      linear subpatterns are merged into a single"""
      node = self
      subp = []
      while node:
          if node.type == TYPE_ALTERNATIVES:
              node.alternatives.append(subp)
              if len(node.alternatives) == len(node.children):
                  # last alternative
                  subp = [tuple(node.alternatives)]
                  node.alternatives = []
                  node = node.parent
                  continue
              else:
                  node = node.parent
                  subp = None
                  break
  
          if node.type == TYPE_GROUP:
              node.group.append(subp)
              # probably should check the number of leaves
              if len(node.group) == len(node.children):
                  subp = get_characteristic_subpattern(node.group)
                  node.group = []
                  node = node.parent
                  continue
              else:
                  node = node.parent
                  subp = None
                  break
  
          if node.type == token_labels.NAME and node.name:
              # in case of type=name, use the name instead
              subp.append(node.name)
          else:
              subp.append(node.type)
  
          node = node.parent
      return subp
  
file_path: catboost/contrib/tools/python/src/Lib/lib2to3/btm_utils.py
imports: from .None import pytree
  from .pgen2 import grammar, token
  from .pygram import pattern_symbols, python_symbols
label_desc: Use image node_id 3 for calling the MinNode obj's underlying member method code with example usage: obj.leaf_to_root() and returns: subp