void (Predicate<PyFrameAccessor> ifClose) { List<TabInfo> tabsToRemove = new ArrayList<>(); for (TabInfo info : myTabs.getTabs()) { if (ifClose.test(getPanel(info).getFrameAccessor())) { tabsToRemove.add(info); } } ApplicationManager.getApplication().invokeLater(() -> { for (TabInfo info : tabsToRemove) { myTabs.removeTab(info); getPanel(info).closeEditorTabs(); } }); }