private static void replaceModel(@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();
  }
private static void replaceModel(@NotNull MyTree tree, @NotNull AsyncTreeModel model, @NotNull TreeExpansionMonitor<?> monitor)