code: private void toggleSelection(TreePath path)
      {
          Object node = path.getLastPathComponent();
          State state = getSelectionState(node);
          if (state == null)
          {
              return;
          }
          if (state == State.SELECTED)
          {
              setSelectionState(node, State.UNSELECTED);
              updateSelection(node);
          }
          else if (state == State.UNSELECTED)
          {
              setSelectionState(node, State.SELECTED);
              updateSelection(node);
          }
          else
          {
              setSelectionState(node, State.SELECTED);
              updateSelection(node);
          }
          
      }
docs: Toggle the selection of the given path due to a mouse click
  
  @param path The path