An implementation of a Python-like yield(...) method in Java