code: def _all_simple_paths_graph(G, source, targets, cutoff):
      visited = dict.fromkeys([source])
      stack = [iter(G[source])]
      while stack:
          children = stack[-1]
          child = next(children, None)
          if child is None:
              stack.pop()
              visited.popitem()
          elif len(visited) < cutoff:
              if child in visited:
                  continue
              if child in targets:
                  yield list(visited) + [child]
              visited[child] = None
              if targets - set(
                  visited.keys()
              ):  # expand stack until find all targets
                  stack.append(iter(G[child]))
              else:
                  visited.popitem()  # maybe other ways to child
          else:  # len(visited) == cutoff:
              for target in (targets & (set(children) | {child})) - set(
                  visited.keys()
              ):
                  yield list(visited) + [target]
              stack.pop()
              visited.popitem()
  
file_path: catboost/contrib/python/pythran/pythran/graph.py
label_desc: Use image node_id 2 for calling a global function with example usage: _all_simple_paths_graph(G, source, targets, cutoff) without return types