I have the following structure: a known number of objects, each of which contains an unknown number of arrays (the size and contents of each array is known). Each array is a “solution”, where each element is a reference to another object.
How would I go about filling a list of lists, where each list contains every object reference contained in a single permutation of the above structure? For example, say I have 2 objects, like so:
Object 1:
Solution 1: Object 1, Object 2
Solution 2: Object 2, Object 3
Object 2:
Solution 1: Object 3, Object 4
I would want to end up with the following list of lists: (brackets for clarification only – each bracketed set is a single object’s “solution”, as shown above)
List 1: (Object 1, Object 2), (Object 3, Object 4)
List 2: (Object 2, Object 3), (Object 3, Object 4)
I know that I need some kind of recursive function; I have tried implementing a version of the function described here  java  Generate all combinations from multiple lists  Stack Overflow  but what ends up happening is that each list contains every object reference in all permutations. This is the function I wrote (scr_tile is the name of the object I am talking about):
void GeneratePermutations(List<List<scr_tile[]>> Lists, List<List<scr_tile>> result, int depth, List<scr_tile> current) {
if (depth == Lists.Count) {
result.Add(current);
return;
}
for (int i = 0; i < Lists[depth].Count; ++i) {
List<scr_tile> new_current = current;
new_current.AddRange(Lists[depth]*);*

GeneratePermutations(Lists, result, depth + 1, new_current);*
 }*
}
And I call it using the following (also including the code used to populate Lists – shape_solutions is simply the list for each scr_tile, which contains arrays, where each array represents a single “solution”):
List<List<scr_tile[]>> Lists = new List<List<scr_tile[]>>();
foreach (scr_tile tile in (scr_tile[])Object.FindObjectsOfType(typeof(scr_tile))) {  tile.GetShapeSolutions();*
 if (tile.shape_solutions.Count > 0 && !Lists.Contains(tile.shape_solutions)) Lists.Add(tile.shape_solutions);*
}
List<List<scr_tile>> Result = new List<List<scr_tile>>();
GeneratePermutations(Lists, Result, 0, new List<scr_tile>());
So I feel like the above function could be modified in some relatively simple way to store these permutations properly – but I am beating my head against a wall at the moment. I have tried tinkering with it in a few ways. I know basically nothing about recursive functions so they are not very intuitive to me, so assume zero knowledge of the subject matter.
I hope that all made sense. It is 3am, so…
Any help would be massively appreciated.