boolean (@NotNull PsiExpression expression) { final PsiExpression[] exprWithWriteAccessInside = new PsiExpression[1]; expression.accept(new JavaRecursiveElementWalkingVisitor() { @Override public void visitElement(@NotNull PsiElement element) { if (exprWithWriteAccessInside[0] != null) return; super.visitElement(element); } @Override public void visitExpression(@NotNull PsiExpression expression) { if (PsiUtil.isAccessedForWriting(expression)) { exprWithWriteAccessInside[0] = expression; } super.visitExpression(expression); } }); return exprWithWriteAccessInside[0] != null; }