class_docstr: The main matcher class. After instantiating the patterns should
  be added using the add_fixer method
docstr: Recursively adds a linear pattern to the AC automaton
docstr_tok: ["Recursively","adds","a","linear","pattern","to","the","AC","automaton"]
code: def add(self, pattern, start):
      "Recursively adds a linear pattern to the AC automaton"
      # print("adding pattern", pattern, "to", start)
      if not pattern:
          # print("empty pattern")
          return [start]
      if isinstance(pattern[0], tuple):
          # alternatives
          # print("alternatives")
          match_nodes = []
          for alternative in pattern[0]:
              # add all alternatives, and add the rest of the pattern
              # to each end node
              end_nodes = self.add(alternative, start=start)
              for end in end_nodes:
                  match_nodes.extend(self.add(pattern[1:], end))
          return match_nodes
      else:
          # single token
          # not last
          if pattern[0] not in start.transition_table:
              # transition did not exist, create new
              next_node = BMNode()
              start.transition_table[pattern[0]] = next_node
          else:
              # transition exists already, follow
              next_node = start.transition_table[pattern[0]]
  
          if pattern[1:]:
              end_nodes = self.add(pattern[1:], start=next_node)
          else:
              end_nodes = [next_node]
          return end_nodes
  
file_path: catboost/contrib/tools/python/src/Lib/lib2to3/btm_matcher.py
imports: import logging
  import itertools
  from collections import defaultdict
  from .None import pytree
  from .btm_utils import reduce_tree
label_desc: Use image node_id 3 for calling the BottomMatcher obj's underlying member method code with example usage: obj.add(pattern, start) and returns: list, match_nodes, end_nodes