That was the type of thing I was trying to put together in my head, but for some reason it just wouldn't come together. That code seems to work perfectly, although, I haven't tested it more than 1 level deep, yet.
As for the DIV problem, how would you suggest fixing that?