private static List<StructField<?>> getFields(Struct struct, int depth, ArrayList<Field> classFields) {// ,
                                                                                                           // final
                                                                                                           // List<Field>
                                                                                                           // fieldList)
                                                                                                           // {
        ArrayList<StructField<?>> structFields = new ArrayList<StructField<?>>();

        Class<? extends Struct> structClass = struct.getClass();
        try {
            // for each class field
            // Extract class fields into a StructField List
            // (Note: class methods are iterated in undefined order)
            Field[] fields = structClass.getDeclaredFields();
            for (Field field : fields) {
                field.setAccessible(true);

                Object o = field.get(struct);
                if (o instanceof StructField) {
                    if (classFields != null) classFields.add(field);
                    StructField<?> so = (StructField<?>) o;
                    structFields.add(so);
                }
            }

            // Sort by position
            sortFields(structFields);

            ArrayList<StructField<?>> expandedStructFields = new ArrayList<StructField<?>>();

            // Expand sub struct and arrays to flat list
            for (int i = 0; i < structFields.size(); i++) {
                StructField<?> so = structFields.get(i);
                if (so.getValue() instanceof Struct) { // substruct
                    List<StructField<?>> subStruct = getFields((Struct) so.getValue(), depth + 1, classFields);
                    expandedStructFields.addAll(subStruct);
                } else if (so.getValue().getClass().isArray() && Struct.class.isAssignableFrom(so.getValue().getClass().getComponentType())) { // array
                                                                                                                                               // of
                                                                                                                                               // substruct

                    Struct[] subA = (Struct[]) so.getValue();
                    for (int j = 0; j < subA.length; j++) {
                        Struct sub = subA[j];
                        List<StructField<?>> subStruct = getFields(sub, depth + 1, classFields);
                        expandedStructFields.addAll(subStruct);
                    }

                } else {
                    so.setDepth(depth);
                    so.setGroup(struct.hashCode());
                    expandedStructFields.add(so);
                }
            }
            structFields = expandedStructFields;

            // Recompute positions in flat list
            int i = 0;
            for (StructField<?> so : structFields) {
                so.setPosition(i);
                i++;
            }

        } catch (final Exception e) {
            throw new RuntimeException(e);
        }
        assert structFields.size() != 0;
        return structFields;
    }
Get sorted List of StructFields from a Struct object

@param struct
           the struct object
@return the sorted list
jme3-core/src/main/java/com/jme3/util/struct/StructUtils.java