List<PsiStatement> (@Nullable PsiStatement last) { if (last == null) return Collections.emptyList(); List<PsiStatement> terminatingStatements = new ArrayList<>(); PsiIfStatement ifStatement = tryCast(last, PsiIfStatement.class); if (ifStatement != null) { PsiStatement[] thenStatements = ControlFlowUtils.unwrapBlock(ifStatement.getThenBranch()); terminatingStatements.addAll(getTerminatingStatements(ArrayUtil.getLastElement(thenStatements))); PsiStatement elseBranch = ifStatement.getElseBranch(); if (elseBranch != null) { PsiStatement[] elseStatements = ControlFlowUtils.unwrapBlock(elseBranch); terminatingStatements.addAll(getTerminatingStatements(ArrayUtil.getLastElement(elseStatements))); } } else { terminatingStatements.add(last); } return terminatingStatements; }