I've committed a fix.
FWIW, I went back and checked the original SmartThings doc. I don't think nested sections were ever supported, they just happened to work. And in this particular case, I'm not sure they are actually helpful.
This code is pretty crufty at this point. It could stand a complete rewrite.