@Override
    public Spatial next() {
        if (main != null) {
            current = main;
            main = null;
        } else {
            current = path.getLast().iterator.next();
            if (current instanceof Node) {
                Node n = (Node)current;
                if (!n.getChildren().isEmpty()) {
                    path.addLast(new PathNode(n));
                    depth++;
                }
            }
        }
        return current;
    }
Instantiates a new {@code SceneGraphIterator} instance that
starts iterating at the given main spatial.

@param main the main spatial to start iteration from
jme3-core/src/main/java/com/jme3/scene/SceneGraphIterator.java