void (@Nullable Runnable onDone) { JTree tree = getTree(); if (tree.getRowCount() > 0) { int expandRecursionDepth = Math.max(2, Registry.intValue("ide.tree.expandRecursionDepth")); new TreeRunnable("AbstractTreeUi.expandAll") { private int myCurrentRow; private int myInvocationCount; @Override public void perform() { if (++myInvocationCount > expandRecursionDepth) { myInvocationCount = 0; if (isPassthroughMode()) { run(); } else { // need this to prevent stack overflow if the tree is rather big and is "synchronous" SwingUtilities.invokeLater(this); } } else { int row = myCurrentRow++; if (row < tree.getRowCount()) { TreePath path = tree.getPathForRow(row); Object last = path.getLastPathComponent(); Object elem = getElementFor(last); expand(elem, this); } else { runDone(onDone); } } } }.run(); } else { runDone(onDone); } }