code: def _join(segments):
      
      new = []
      start = segments[0][0]
      end = segments[0][1]
      for i in range(len(segments)-1):
          if segments[i+1][0] != segments[i][1]:
              new.append((start, end))
              start = segments[i+1][0]
          end = segments[i+1][1]
      new.append((start, end))
      return new
docs: simply list by joining adjacent segments.