List<PsiExpression> (@NotNull PsiExpression originalExpr) { PsiVariable variable = findVariableByInitializer(originalExpr); PsiCodeBlock nearestBody = DuplicateExpressionsContext.findNearestBody(originalExpr); if (variable != null && nearestBody != null) { List<PsiExpression> replaceableOccurrences = new ArrayList<>(); nearestBody.accept(new JavaRecursiveElementWalkingVisitor() { final ExpressionHashingStrategy hashingStrategy = new ExpressionHashingStrategy(); @Override public void visitExpression(@NotNull PsiExpression occurrence) { super.visitExpression(occurrence); if (occurrence != originalExpr && hashingStrategy.equals(occurrence, originalExpr) && canReplaceWith(occurrence, variable)) { replaceableOccurrences.add(occurrence); } } }); return replaceableOccurrences; } return Collections.emptyList(); }