boolean (@NotNull PsiStatement statement, @NotNull PsiVariable last) { PsiIfStatement ifStatement = tryCast(statement, PsiIfStatement.class); if (ifStatement == null || ifStatement.getElseBranch() != null) return false; PsiBinaryExpression binaryExpression = tryCast(ifStatement.getCondition(), PsiBinaryExpression.class); if (binaryExpression == null) return false; if (!ExpressionUtils.isReferenceTo(ExpressionUtils.getValueComparedWithZero(binaryExpression, JavaTokenType.NE), last)) return false; PsiStatement thenStmt = ControlFlowUtils.stripBraces(ifStatement.getThenBranch()); if (!(thenStmt instanceof PsiReturnStatement)) return false; return ExpressionUtils.isReferenceTo(((PsiReturnStatement)thenStmt).getReturnValue(), last); }