I would like to implement an Iterator in Java that behaves somewhat like the following generator function in Python:
def iterator(array):
for x in array:
if x!= None:
for y in x:
if y!= None:
for z in y:
if z!= None:
yield z
x on the java side can be multi-dimensional array or some form of nested collection. I am not sure how this would work. Ideas?