private static int arrayDataToFlat(final Object data, final Object flat, int offset) {
        final Class<?> klass = data.getClass().getComponentType();
        final int length = Array.getLength(data);
        if (klass.isArray()) {
            for (int i = 0; i < length; i++) {
                offset = PyMultiarray.arrayDataToFlat(
                        Array.get(data, i),
                        flat,
                        offset);
            }
            return offset;
        }
        System.arraycopy(data, 0, flat, offset, length);
        return offset + length;
    }