'Rebuild the category tree, expand any categories that were expanded,
reset the search states, and reselect the current node.'

def recount(self, *args):

    if (self.disable_recounting or (not self.pane_is_visible)):
        return
    self.refresh_signal_processed = True
    ci = self.currentIndex()
    if (not ci.isValid()):
        ci = self.indexAt(QPoint(10, 10))
    use_pos = self._model.use_position_based_index_on_next_recount
    self._model.use_position_based_index_on_next_recount = False
    if use_pos:
        path = (self._model.path_for_index(ci) if self.is_visible(ci) else None)
    else:
        path = (self._model.named_path_for_index(ci) if self.is_visible(ci) else None)
    (expanded_categories, state_map) = self.get_state()
    self._model.rebuild_node_tree(state_map=state_map)
    self.blockSignals(True)
    for category in expanded_categories:
        idx = self._model.index_for_category(category)
        if ((idx is not None) and idx.isValid()):
            self.expand(idx)
    if (path is not None):
        if use_pos:
            self.show_item_at_path(path)
        else:
            index = self._model.index_for_named_path(path)
            if index.isValid():
                self.show_item_at_index(index)
    self.blockSignals(False)
