>>> from Redy.Collections import Traversal, Flow
    >>> lst: Iterable[int] = [[1, 2, 3]]
    >>> x = Flow(lst)[Traversal.flatten_to(int)]
    >>> assert isinstance(x.unbox, Generator) and list(x.unbox) == [1, 2, 3]

def flatten_to(atom: Union[Tuple[Type[T]], Type[T]]):
    """
    >>> from Redy.Collections import Traversal, Flow
    >>> lst: Iterable[int] = [[1, 2, 3]]
    >>> x = Flow(lst)[Traversal.flatten_to(int)]
    >>> assert isinstance(x.unbox, Generator) and list(x.unbox) == [1, 2, 3]
    """

    def inner(nested: ActualIterable[Union[T, ActualIterable[T]]]) -> ActualIterable[T]:
        for each in nested:
            if isinstance(each, atom):
                yield each
            else:
                yield from inner(each)

    return inner