private void trim() {
        if (!path.isEmpty() && !path.getLast().iterator.hasNext()) {
            path.removeLast();
            depth--;
            trim();
        }
    }
Trims the path to the first unexhausted node.
jme3-core/src/main/java/com/jme3/scene/SceneGraphIterator.java