public static void expandRootChildIfOnlyOne(final @Nullable JTree tree) {
    if (tree == null) return;
    Runnable runnable = () -> {
      TreeModel model = tree.getModel();
      Object root = model.getRoot();
      if (root == null) return;
      TreePath rootPath = new CachingTreePath(root);
      tree.expandPath(rootPath);
      if (model.getChildCount(root) == 1) {
        Object firstChild = model.getChild(root, 0);
        tree.expandPath(rootPath.pathByAddingChild(firstChild));
      }
    };
    EdtInvocationManager.invokeLaterIfNeeded(runnable);
  }
public static void expandRootChildIfOnlyOne(final @Nullable JTree tree)