code: def expandBranch(self, index=None, expanded=None):
          
          configModel = self.model()
          if index is None:
              #index = configTreeModel.createIndex()
              index = QtCore.QModelIndex()
  
          if index.isValid():
              if expanded is None:
                  item = configModel.getItem(index)
                  self.setExpanded(index, item.expanded)
              else:
                  self.setExpanded(index, expanded)
  
          for rowNr in range(configModel.rowCount(index)):
              childIndex = configModel.index(rowNr, configModel.COL_NODE_NAME, parentIndex=index)
              self.expandBranch(index=childIndex, expanded=expanded)
docs: Expands or collapses the node at the index and all it's descendants.
              If expanded is True the nodes will be expanded, if False they will be collapsed, and if
              expanded is None the expanded attribute of each item is used.
              If parentIndex is None, the invisible root will be used (i.e. the complete forest will
              be expanded).