code: public Category getSelectedCategory() {
      TreeItem<Category> selectedTreeItem =
          navigationView.treeView.getSelectionModel().getSelectedItem();
      if (selectedTreeItem != null) {
        return navigationView.treeView.getSelectionModel().getSelectedItem().getValue();
      }
      return null;
    }
docs: Retrieves the currently selected category in the TreeSearchView.