<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def group_modes(modes):
 """ Groups consecutive transportation modes with same label, into one Args: modes (:obj:`list` of :obj:`dict`) Returns: :obj:`list` of :obj:`dict` """

    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