I have a problem that is really kind of a general programming question, but my implementation is in Java, so I will provide my examples that way
I have a class like
Guava has a utility method which returns a cartesian product of the given list of sets: Sets.cartesianProduct.