PsiElementPredicate () { return e -> { if (!e.getNode().getElementType().equals(GroovyTokenTypes.kIF)) return false; if (!(e.getParent() instanceof GrIfStatement ifStatement)) return false; final PsiElement thenBranch = skipBlock(ifStatement.getThenBranch()); final PsiElement elseBranch = skipBlock(ifStatement.getElseBranch()); if (thenBranch instanceof GrAssignmentExpression thenAssign && thenAssign.getRValue() != null && elseBranch instanceof GrAssignmentExpression elseAssign && elseAssign.getRValue() != null) { final GrExpression lvalue1 = thenAssign.getLValue(); final GrExpression lvalue2 = elseAssign.getLValue(); return EquivalenceChecker.expressionsAreEquivalent(lvalue1, lvalue2); } if (thenBranch instanceof GrReturnStatement thenReturn && thenReturn.getReturnValue() != null && elseBranch instanceof GrReturnStatement elseReturn && elseReturn.getReturnValue() != null) { return true; } return false; }; }