boolean (@NotNull PsiElement element) { if (!(element.getNode().getElementType() == GroovyTokenTypes.kELSE)) return false; final PsiElement parent = element.getParent(); if (!(parent instanceof GrIfStatement ifStatement)) return false; final GrStatement branch = ifStatement.getThenBranch(); final GrControlFlowOwner flowOwner = ControlFlowUtils.findControlFlowOwner(ifStatement); if (flowOwner == null) return false; final Instruction[] flow = flowOwner.getControlFlow(); for (Instruction instruction : flow) { if (instruction instanceof IfEndInstruction && instruction.getElement() == ifStatement) { for (Instruction pred : instruction.allPredecessors()) { final PsiElement predElement = pred.getElement(); if (predElement != null && PsiTreeUtil.isAncestor(branch, predElement, false)) { return false; } } } } return true; }