<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def expand(sequence):
 """ expands a tree of sequences into a single, flat sequence, recursively. """

    expanse = []
    for point in sequence:
        if 'sequence' in point:
            expanse.extend(expand(point['sequence']))
        else:
            expanse.append(point)
    return sequence.__class__(expanse)