def METHOD_NAME(level):
    if isinstance(level, Rational):
        elements.extend(
            [level.get_head(), level.numerator(), level.denominator()]
        )
    elif isinstance(level, Complex):
        elements.extend([level.get_head(), level.real, level.imag])
    else:
        elements.append(level)
    return level