code: def group_modes(modes):
      
      if len(modes) > 0:
          previous = modes[0]
          grouped = []
  
          for changep in modes[1:]:
              if changep['label'] != previous['label']:
                  previous['to'] = changep['from']
                  grouped.append(previous)
                  previous = changep
  
          previous['to'] = modes[-1]['to']
          grouped.append(previous)
          return grouped
      else:
          return modes
docs: Groups consecutive transportation modes with same label, into one
  
      Args:
          modes (:obj:`list` of :obj:`dict`)
      Returns:
          :obj:`list` of :obj:`dict`