code: def get_paths_to_simplify(G, strict=True):
      
  
      # first identify all the nodes that are endpoints
      start_time = time.time()
      endpoints = set([node for node in G.nodes() if is_endpoint(G, node, strict=strict)])
      log('Identified {:,} edge endpoints in {:,.2f} seconds'.format(len(endpoints), time.time()-start_time))
  
      start_time = time.time()
      paths_to_simplify = []
  
      # for each endpoint node, look at each of its successor nodes
      for node in endpoints:
          for successor in G.successors(node):
              if successor not in endpoints:
                  # if the successor is not an endpoint, build a path from the
                  # endpoint node to the next endpoint node
                  try:
                      path = build_path(G, successor, endpoints, path=[node, successor])
                      paths_to_simplify.append(path)
                  except RuntimeError:
                      log('Recursion error: exceeded max depth, moving on to next endpoint successor', level=lg.WARNING)
                      # recursion errors occur if some connected component is a
                      # self-contained ring in which all nodes are not end points.
                      # could also occur in extremely long street segments (eg, in
                      # rural areas) with too many nodes between true endpoints.
                      # handle it by just ignoring that component and letting its
                      # topology remain intact (this should be a rare occurrence)
                      # RuntimeError is what Python <3.5 will throw, Py3.5+ throws
                      # RecursionError but it is a subtype of RuntimeError so it
                      # still gets handled
  
      log('Constructed all paths to simplify in {:,.2f} seconds'.format(time.time()-start_time))
      return paths_to_simplify
docs: Create a list of all the paths to be simplified between endpoint nodes.
  
      The path is ordered from the first endpoint, through the interstitial nodes,
      to the second endpoint. If your street network is in a rural area with many
      interstitial nodes between true edge endpoints, you may want to increase
      your system's recursion limit to avoid recursion errors.
  
      Parameters
      ----------
      G : networkx multidigraph
      strict : bool
          if False, allow nodes to be end points even if they fail all other rules
          but have edges with different OSM IDs
  
      Returns
      -------
      paths_to_simplify : list