code: def reduce(self) -> None:
          
          idx = 0
          while idx < len(self):
              if idx > 0 and \
                      self[idx - 1].type == 'text' and self[idx].type == 'text':
                  self[idx - 1].data['text'] += self[idx].data['text']
                  del self[idx]
              else:
                  idx += 1
docs: Remove redundant segments.
  
          Since this class is implemented based on list,
          this method may require O(n) time.