private static List<Geometry> listGeometries(Spatial subtree,
            List<Geometry> addResult) {
        List<Geometry> result = (addResult == null) ? new ArrayList<>(50) : addResult;

        if (subtree instanceof Geometry) {
            Geometry geometry = (Geometry) subtree;
            if (!result.contains(geometry)) {
                result.add(geometry);
            }
        }

        if (subtree instanceof Node) {
            Node node = (Node) subtree;
            List<Spatial> children = node.getChildren();
            for (Spatial child : children) {
                listGeometries(child, result);
            }
        }

        return result;
    }
Enumerate all geometries in the specified subtree of a scene graph. Note:
recursive!

@param subtree (not null, aliases created)
@param addResult (added to if not null)
@return an expanded list (either storeResult or a new instance)
jme3-jbullet/src/main/java/com/jme3/bullet/animation/RagUtils.java