PsiExpression (IterableTraversal traversal, PsiIfStatement ifStatement) { PsiExpression condition = ifStatement.getCondition(); if (condition == null || ifStatement.getElseBranch() != null) return null; PsiStatement thenStatement = ControlFlowUtils.stripBraces(ifStatement.getThenBranch()); if (!(thenStatement instanceof PsiExpressionStatement)) return null; if (!traversal.isRemoveCall(((PsiExpressionStatement)thenStatement).getExpression())) return null; if (!LambdaGenerationUtil.canBeUncheckedLambda(condition)) return null; PsiReferenceExpression iterable = tryCast(PsiUtil.skipParenthesizedExprDown(traversal.getIterable()), PsiReferenceExpression.class); PsiVariable iterableVariable = iterable != null ? tryCast(iterable.resolve(), PsiVariable.class) : null; if (iterableVariable != null && VariableAccessUtils.variableIsUsed(iterableVariable, condition)) return null; return condition; }