void (Condition<? super TreeNode> nodeFilter, Condition<? super TreeNode> obsoleteChecker) { addTreeListener(new XDebuggerTreeListener() { @Override public void nodeLoaded(@NotNull RestorableStateNode node, @NotNull String name) { if (obsoleteChecker.value(node)) { removeTreeListener(this); } if (nodeFilter.value(node)) { setSelectionPath(node.getPath()); removeTreeListener(this); // remove the listener on first match } } }); }