code: def split_traversal(traversal,
                      edges,
                      edges_hash=None):
      traversal = np.asanyarray(traversal,
                                dtype=np.int64)
      if edges_hash is None:
          edges_hash = grouping.hashable_rows(
              np.sort(edges, axis=1))
      trav_edge = np.column_stack((traversal[:-1],
                                   traversal[1:]))
      trav_hash = grouping.hashable_rows(
          np.sort(trav_edge, axis=1))
      contained = np.in1d(trav_hash, edges_hash)
      if contained.all():
          split = [traversal]
      else:
          blocks = grouping.blocks(contained,
                                   min_len=1,
                                   only_nonzero=True)
          split = [np.append(trav_edge[b][:, 0],
                             trav_edge[b[-1]][1])
                   for b in blocks]
      for i, t in enumerate(split):
          split[i] = np.asanyarray(split[i], dtype=np.int64)
          if len(t) <= 2:
              continue
          edge = np.sort([t[0], t[-1]])
          if edge.ptp() == 0:
              continue
          close = grouping.hashable_rows(edge.reshape((1, 2)))[0]
          if close in edges_hash:
              split[i] = np.append(t, t[0]).astype(np.int64)
      result = np.array(split)
      return result