def flatten(nl):
    """Flattens a nested list/tuple/set, returns list"""
    if isinstance(nl, (tuple, set)):
        nl = list(nl)

    # noinspection PySimplifyBooleanCheck
    if nl == []:  # don't change this
        return nl

    if isinstance(nl[0], (list, tuple, set)):
        return flatten(list(nl)[0]) + flatten(list(nl)[1:])
    return nl[:1] + flatten(nl[1:])