from typing import Union
from typing import List
from typing import Tuple


def flatten(xs: Union[List, Tuple]) -> List:
    """ Flatten a nested list or tuple. """
    return (
        sum(map(flatten, xs), [])
        if (isinstance(xs, list) or isinstance(xs, tuple))
        else [xs]
    )