Currently trees define branches as "might have children". This changes that to "actually has children".

Replaces #882. Cherry-picked @fairbanksg's branch over on top of latest master. (Sorry Greg, the jshint cleanup commit didn't make it. Those are dangerous unless they manage to make it into master right away.)