void (MapCheckCondition condition, PsiStatement existsBranch, PsiStatement noneBranch) { if(noneBranch instanceof PsiExpressionStatement && existsBranch instanceof PsiExpressionStatement) { PsiExpression absentValue = extractPutValue(condition, noneBranch); if (absentValue == null) return; PsiExpression presentValue = extractPutValue(condition, existsBranch); if (presentValue == null || !LambdaGenerationUtil.canBeUncheckedLambda(presentValue)) return; // absentValue should not refer map if (!PsiTreeUtil.processElements(absentValue, e -> !condition.isMap(e))) return; boolean hasVariable = condition.hasVariable(); if (hasVariable && PsiTreeUtil.collectElements(presentValue, condition::isValueReference).length == 0) return; PsiElement[] mapRefs = PsiTreeUtil.collectElements(presentValue, condition::isMap); if(hasVariable ^ mapRefs.length == 0) return; for(PsiElement mapRef : mapRefs) { PsiElement parent = mapRef.getParent(); if (!(parent instanceof PsiReferenceExpression) || condition.extractGetCall(parent.getParent()) == null) return; } if (PsiTreeUtil.collectElements(presentValue, e -> PsiEquivalenceUtil.areElementsEquivalent(e, absentValue)).length == 0) { return; } if (NullabilityUtil.getExpressionNullability(absentValue) == Nullability.NULLABLE || NullabilityUtil.getExpressionNullability(presentValue) == Nullability.NULLABLE) { return; } boolean informationLevel = !mySideEffects && SideEffectChecker.mayHaveSideEffects(presentValue, ex -> condition.extractGetCall(ex) != null); register(condition, holder, informationLevel, new ReplaceWithSingleMapOperation("merge", PsiTreeUtil .getParentOfType(absentValue, PsiMethodCallExpression.class), presentValue, noneBranch)); } }