boolean (@NotNull FoldRegion region) { FoldingGroup group = region.getGroup(); List<FoldRegion> affectedRegions = group != null && myEditor instanceof EditorEx ? ((EditorEx)myEditor).getFoldingModel().getGroupedRegions(group) : Collections.singletonList(region); for (FoldRegion affectedRegion : affectedRegions) { if (regionCanBeRemovedWhenCollapsed(affectedRegion)) return true; } return false; }