I have a data feed that can have a repetetive array structure nested up to 4 or 5 levels deep. Sometimes, the data stops at the first level, but it can go 2 or more times deeper. To further complicate the matter, when testing at each level, there can be 3 alternate outcomes at each level: 1) There is no further branching 2) there is a single branch or 3) there are multiple branches. Let me show you some of the possible array structures below:
[groups][group][subjects][subject]
[groups][group][groups][group][subjects][subject]
[groups][group][1][groups][group][subjects][subject]
[groups][group][0][groups][group][1][subjects][subject]
[groups][group][1][groups][group][groups][group][0][subjects][subject]
[groups][group][0][groups][group][1][groups][group][groups][group][subjects][subject]
[groups][group][groups][group][1][subjects][subject]
As you can see, the [groups][group] array structure varies on any given iteration of data that I import. I built a test to determine which of three outcomes is at each level, but I am stumped on how to recurse it through the tree, as each branch has 3 possible outcomes at every level. Can someone point me out a basic methodology or algorithm that can do this? Otherwise, I'll have to write out the complete tree of possibilities, which is a huge waste of code...
Any assistance would be greatly appreciated!