Smarter traversal for element nodes with no children