That's pretty much what I've thought about so far. The place where my brain just starts to smoke is the switches. Not only does a switch have one 'in' and two 'out' paths, but if you flip it over, one 'out' is in the same place and the other 'out' is in a third place.
I just can't figure out how the recursion would work in that situation. Fortunately, I'm too busy with paying work to figure that out right now.