from typing import Iterable
from typing import Iterator


def flatten_iterator(*args: Iterable, depth=None) -> Iterator:
    """
    Iterates and flattens iterables recursively according to the specified depth.

    If depth=None (the default) it flattens recursively until it finds no iterable.

    >>> type(flatten_iterator([1, 2, [3, 4, ['cinco']]]))
    <class 'generator'>
    >>> list(flatten_iterator([1, 2, [3, 4, ['cinco']]]))
    [1, 2, 3, 4, 'cinco']
    >>> list(flatten_iterator([1, 2, [3, 4, ['cinco']]], depth=1))
    [1, 2, [3, 4, ['cinco']]]
    >>> list(flatten_iterator([1, 2, [3, 4, ['cinco']]], depth=2))
    [1, 2, 3, 4, ['cinco']]
    """

    current_depth = -1

    def flatten_iterator_(*args_: Iterable, depth_=None) -> Iterator:
        nonlocal current_depth

        if depth_ is not None:
            current_depth += 1

        for arg_ in args_:
            if isinstance(arg_, Iterable) and not isinstance(arg_, (str, bytes)) and (depth_ is None or current_depth < depth_):
                yield from flatten_iterator_(*arg_, depth_=depth_)
                if depth_ is not None:
                    current_depth -= 1
            else:
                yield arg_

    return flatten_iterator_(*args, depth_=depth)