public static void gatherGeoms(Spatial scene, List<Geometry> geoms) {
        if (scene instanceof Node) {
            Node node = (Node) scene;
            for (Spatial child : node.getChildren()) {
                gatherGeoms(child, geoms);
            }
        } else if (scene instanceof Geometry) {
            geoms.add((Geometry) scene);
        }
    }
Batches a collection of Geometries so that all with the same material get combined.
@param geometries The Geometries to combine
@param useLods true&rarr;generate levels of detail, false&rarr;don't
generate them
@return A List of newly created Geometries, each with a  distinct material
jme3-core/src/tools/java/jme3tools/optimize/GeometryBatchFactory.java