PsiStatement (@Nullable PsiCodeBlock codeBlock) { if (codeBlock == null) return null; for (PsiElement child = codeBlock.getLastChild(); child != null; child = child.getPrevSibling()) { if (child instanceof PsiStatement) { return (PsiStatement)child; } } return null; }