code: protected void toggleSelection(CmsTreeItem item, boolean changeState) {
  
          boolean select = item.getCheckBox().isChecked();
          select = changeState ? !select : select;
          if (m_isSingleSelection) {
              m_selectedCategories.clear();
              uncheckAll(m_scrollList);
          }
          if (select) {
              if (m_isSingleSelection) {
                  m_singleResult = item.getId();
              }
              CmsTreeItem currentItem = item;
              do {
                  currentItem.getCheckBox().setChecked(true);
                  String id = currentItem.getId();
                  if (!m_selectedCategories.contains(id)) {
                      m_selectedCategories.add(id);
                  }
                  currentItem = currentItem.getParentItem();
              } while (currentItem != null);
          } else {
              if (m_isSingleSelection) {
                  m_singleResult = "";
              }
              deselectChildren(item);
              CmsTreeItem currentItem = item;
              do {
                  currentItem.getCheckBox().setChecked(false);
                  String id = currentItem.getId();
                  if (m_selectedCategories.contains(id)) {
                      m_selectedCategories.remove(id);
                  }
                  currentItem = currentItem.getParentItem();
              } while ((currentItem != null) && !hasSelectedChildren(currentItem));
          }
          fireValueChange();
      }
docs: Called if a category is selected/deselected.
  
  The checkbox state of the selected/deselected item has to be the state BEFORE toggling.
  
  @param item the tree item that should be selected/deselected.
  @param changeState flag, indicating if the checkbox state should be changed.