PsiElement (@NotNull PsiElement statement) { final PsiElement parent = statement.getParent(); if (parent instanceof PsiDoWhileStatement && ((PsiDoWhileStatement)parent).getBody() == statement) { return parent; } if (parent instanceof PsiCodeBlock && PsiTreeUtil.getNextSiblingOfType(parent.getFirstChild(), PsiStatement.class) == statement) { final PsiBlockStatement blockStatement = ObjectUtils.tryCast(parent.getParent(), PsiBlockStatement.class); if (blockStatement != null) { final PsiElement blockParent = blockStatement.getParent(); if (blockParent instanceof PsiDoWhileStatement && ((PsiDoWhileStatement)blockParent).getBody() == blockStatement) { return blockParent; } } } return getUnreachableStatementParent(statement); }