def METHOD_NAME(nodes: Iterable[T], next_: NextFunc, _count=None) -> Iterator[T]:
    if _count is None:
        _count = count(1)
    for node in nodes:
        yield node
        yield from METHOD_NAME(next_(node), next_, _count)
    if (i := next(_count)) and i > 20000:
        raise RecursionError(f'The tree has either more then={20000} nodes '
                             f'or most likely it is circular')