Edit: The wording of my question has obviously given the impression that I am only concerned with syntactic sugar. Firstly I wanted to make sure that I had not overlooked an existing iterator. But secondly, to me this iterator seems to describe a very common task. Therefore I wonder whether it is worth building it explicitly, and if so, look if someone already has such a solution in the drawer.