'Root item has been selected: expanding it and collapsing others'

def root_item_selected(self, item):

    for index in range(self.topLevelItemCount()):
        root_item = self.topLevelItem(index)
        if (root_item is item):
            self.expandItem(root_item)
        else:
            self.collapseItem(root_item)
