code: def prune(self, cutoff: int = 2):
          
  
          # Remove redundant paths.
          for node_pair in tqdm(list(permutations(self.nodes(), 2))):
              paths = [
                  list(pairwise(path))
                  for path in nx.all_simple_paths(self, *node_pair, cutoff)
              ]
              if len(paths) > 1:
                  for path in paths:
                      if len(path) == 1:
                          self.delete_edge(*path[0])
                          if any(self.degree(n) == 0 for n in path[0]):
                              self.add_edge(*path[0])
                          break
docs: Prunes the CAG by removing redundant paths. If there are multiple
          (directed) paths between two nodes, this function removes all but the
          longest paths. Subsequently, it restricts the graph to the largest
          connected component.
  
          Args:
              cutoff: The maximum path length to consider for finding redundant
              paths. Higher values of this parameter correspond to more
              aggressive pruning.