List<GrControlFlowOwner> (final PsiFile file, final int offset) { final PsiElement elementAtCaret = file.findElementAt(offset); final List<GrControlFlowOwner> result = new ArrayList<>(); for (GrControlFlowOwner owner = ControlFlowUtils.findControlFlowOwner(elementAtCaret); owner != null && !result.contains(owner); owner = ControlFlowUtils.findControlFlowOwner(owner)) { result.add(owner); } return result; }