private static boolean loopOnlyVariablesChanged(@NotNull PsiArrayAccessExpression arrayAccess,
                                                    @NotNull Set<PsiVariable> declaredVariables) {
      return ExpressionUtils.nonStructuralChildren(arrayAccess.getArrayExpression()).allMatch(child -> {
        PsiArrayAccessExpression childArrayAccess = tryCast(child, PsiArrayAccessExpression.class);
        if (childArrayAccess != null) return loopOnlyVariablesChanged(childArrayAccess, declaredVariables);
        PsiReferenceExpression childRef = tryCast(child, PsiReferenceExpression.class);
        if (childRef != null) return isDeclaredVariable(childRef.resolve(), declaredVariables);
        return true;
      });
    }
private static boolean loopOnlyVariablesChanged(@NotNull PsiArrayAccessExpression arrayAccess,
                                                    @NotNull Set<PsiVariable> declaredVariables)