Changed TreeCleaner so that logic for deciding whether to descend tree,
and for detecting empty elements is separate and different (previously
the same logic was, incorrectly, being used for both).