void (@NotNull MyTree tree, @NotNull AsyncTreeModel model, @NotNull TreeExpansionMonitor<?> monitor) { monitor.freeze(); var oldModel = tree.getModel(); if (oldModel instanceof Disposable disposable) { Disposer.dispose(disposable); } tree.setModel(model); monitor.restoreAsync(); }