@Override
    FieldPathIteratorHandler.ModificationStatus iterateNested(FieldPath fieldPath, int pos, FieldPathIteratorHandler handler) {
        if (pos < fieldPath.size()) {
            switch (fieldPath.get(pos).getType()) {
                case ARRAY_INDEX:
                    final int elemIndex = fieldPath.get(pos).getLookupIndex();
                    return iterateSubset(elemIndex, elemIndex, fieldPath, null, pos + 1, handler);
                case VARIABLE: {
                    FieldPathIteratorHandler.IndexValue val = handler.getVariables().get(fieldPath.get(pos).getVariableName());
                    if (val != null) {
                        int idx = val.getIndex();

                        if (idx == -1) {
                            throw new IllegalArgumentException("Mismatch between variables - trying to iterate through map and array with the same variable.");
                        }

                        if (idx < values.size()) {
                            return iterateSubset(idx, idx, fieldPath, null, pos + 1, handler);
                        } else {
                            return FieldPathIteratorHandler.ModificationStatus.NOT_MODIFIED;
                        }
                    } else {
                        return iterateSubset(0, values.size() - 1, fieldPath, fieldPath.get(pos).getVariableName(), pos + 1, handler);
                    }
                }
                default:
            }
            return iterateSubset(0, values.size() - 1, fieldPath, null, pos, handler);
        } else {
            FieldPathIteratorHandler.ModificationStatus status = handler.modify(this);

            if (status == FieldPathIteratorHandler.ModificationStatus.REMOVED) {
                return status;
            }

            if (handler.onComplex(this)) {
                if (iterateSubset(0, values.size() - 1, fieldPath, null, pos, handler) != FieldPathIteratorHandler.ModificationStatus.NOT_MODIFIED) {
                    status = FieldPathIteratorHandler.ModificationStatus.MODIFIED;
                }
            }

            return status;
        }
    }
FieldValue which encapsulates an Array value

@author Einar M R Rosenvinge
document/src/main/java/com/yahoo/document/datatypes/Array.java