Also, it seems like you're pretty consistently using "child" to mean "descendant". Its fine to do that, I guess, but maybe define your terms in the initial comment up top.