nodes: 0, module; 1, function_definition; 2, function_name:_collapse; 3, parameters; 4, block; 5, identifier:intervals; 6, expression_statement; 7, expression_statement; 8, for_statement; 9, if_statement; 10, comment:"""
      Collapse an iterable of intervals sorted by start coord.
      
      """; 11, assignment; 12, pattern_list; 13, identifier:intervals; 14, block; 15, comparison_operator:span is not None; 16, block; 17, identifier:span; 18, None; 19, identifier:start; 20, identifier:stop; 21, if_statement; 22, identifier:span; 23, None; 24, expression_statement; 25, comparison_operator:span is None; 26, block; 27, elif_clause; 28, elif_clause; 29, yield; 30, identifier:span; 31, None; 32, expression_statement; 33, comparison_operator:start <= span.stop < stop; 34, block; 35, comparison_operator:start > span.stop; 36, block; 37, identifier:span; 38, assignment; 39, identifier:start; 40, attribute; 41, identifier:stop; 42, expression_statement; 43, identifier:start; 44, attribute; 45, expression_statement; 46, expression_statement; 47, identifier:span; 48, call; 49, identifier:span; 50, identifier:stop; 51, assignment; 52, identifier:span; 53, identifier:stop; 54, yield; 55, assignment; 56, identifier:_Interval; 57, argument_list; 58, identifier:span; 59, call; 60, identifier:span; 61, identifier:span; 62, call; 63, identifier:start; 64, identifier:stop; 65, identifier:_Interval; 66, argument_list; 67, identifier:_Interval; 68, argument_list; 69, attribute; 70, identifier:stop; 71, identifier:start; 72, identifier:stop; 73, identifier:span; 74, identifier:start
code: def _collapse(intervals):
      """
      Collapse an iterable of intervals sorted by start coord.
      
      """
      span = None
      for start, stop in intervals:
          if span is None:
              span = _Interval(start, stop)
          elif start <= span.stop < stop:
              span = _Interval(span.start, stop)
          elif start > span.stop:
              yield span
              span = _Interval(start, stop)
      if span is not None:
          yield span