code: def regex_limit(graph, mode, program, address):
      low = mode == LO
      output = []
      threads = ThreadList(program)
      threads.add(Thread(0, address))
      arc = Arc()
      while threads:
          thread = threads.current()
          address = thread.address
          op = program[thread.pc]
          optype = type(op)
  
          if optype is Char:
              if address:
                  arc = graph.find_arc(address, op.c, arc)
                  if arc:
                      if low and arc.accept:
                          return thread.sofar + thread.label
                      advance(thread, arc)
                      threads.add(thread)
          elif optype is Lit:
              if address:
                  labels = op.c
                  for label in labels:
                      arc = graph.find_arc(address, label)
                      if arc is None:
                          return thread.sofar
              elif thread.accept:
                  return thread.sofar
          elif optype is Any:
              if address:
                  if low:
                      arc = graph.arc_at(address, arc)
                  else:
                      for arc in graph.iter_arcs(address):
                          pass
                  advance(thread, arc, arc.label)
                  threads.add(thread)
              elif thread.accept:
                  return thread.sofar
          elif op is Match:
              return thread.sofar
          else:
              raise Exception("Don't know what to do with %r" % op)
  
imports: from whoosh.automata.fst import Arc
label_desc: Use image node_id 9 for calling a global function with example usage: regex_limit(graph, mode, program, address) and returns: unknown, thread, thread, thread, thread