def flatten(container, t: type):
    """Flatten into a list of elements of type t."""

    def _flatten(container, t):
        for i in container:
            if isinstance(i, t):
                yield i
            else:
                for j in _flatten(i, t):
                    yield j

    return list(_flatten(container, t))