You can use Iterators.product:
Iterators.product
for elements in Iterators.product(arrays...) do_stuff(elements) end