boolean (PsiExpression condition, PsiVariable iterator) { condition = PsiUtil.skipParenthesizedExprDown(condition); if (!(condition instanceof PsiMethodCallExpression call)) { return false; } if (!call.getArgumentList().isEmpty()) { return false; } final PsiReferenceExpression methodExpression = call.getMethodExpression(); final String methodName = methodExpression.getReferenceName(); if (!HardcodedMethodConstants.HAS_NEXT.equals(methodName)) { return false; } final PsiExpression qualifier = methodExpression.getQualifierExpression(); return ExpressionUtils.isReferenceTo(qualifier, iterator); }