code: def range_piles(ranges):
      
      endpoints = _make_endpoints(ranges)
  
      for seqid, ends in groupby(endpoints, lambda x: x[0]):
          active = []
          depth = 0
          for seqid, pos, leftright, i, score in ends:
              if leftright == LEFT:
                  active.append(i)
                  depth += 1
              else:
                  depth -= 1
  
              if depth == 0 and active:
                  yield active
                  active = []
docs: Return piles of intervals that overlap. The piles are only interrupted by
      regions of zero coverage.
  
      >>> ranges = [Range("2", 0, 1, 3, 0), Range("2", 1, 4, 3, 1), Range("3", 5, 7, 3, 2)]
      >>> list(range_piles(ranges))
      [[0, 1], [2]]