PsiElement (@NotNull PsiElement targetNode) { if (targetNode instanceof PsiCodeBlock && ((PsiCodeBlock)targetNode).getStatementCount() == 1) { PsiElement targetNodeParent = targetNode.getParent(); if (targetNodeParent instanceof PsiBlockStatement) { targetNodeParent = targetNodeParent.getParent(); } if (targetNodeParent instanceof PsiIfStatement || targetNodeParent instanceof PsiLoopStatement) { targetNode = targetNodeParent; } } return targetNode; }