code: def derived_sequence(graph):
      
      deriv_seq = [graph]
      deriv_interv = []
      single_node = False
  
      while not single_node:
  
          interv_graph, interv_heads = intervals(graph)
          deriv_interv.append(interv_heads)
  
          single_node = len(interv_graph) == 1
          if not single_node:
              deriv_seq.append(interv_graph)
  
          graph = interv_graph
          graph.compute_rpo()
  
      return deriv_seq, deriv_interv
docs: Compute the derived sequence of the graph G
      The intervals of G are collapsed into nodes, intervals of these nodes are
      built, and the process is repeated iteratively until we obtain a single
      node (if the graph is not irreducible)