boolean (PsiStatement statement) { if (!(statement instanceof PsiIfStatement ifStatement)) { return false; } if (ifStatement.getElseBranch() != null) { return false; } final PsiStatement thenBranch = ifStatement.getThenBranch(); if (thenBranch instanceof PsiReturnStatement) { return true; } if (!(thenBranch instanceof PsiBlockStatement blockStatement)) { return false; } final PsiCodeBlock codeBlock = blockStatement.getCodeBlock(); final PsiStatement containedStatement = ControlFlowUtils.getOnlyStatementInBlock(codeBlock); return containedStatement instanceof PsiReturnStatement; }