<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def expandBranch(self, index=None, expanded=True):
 """ 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. If parentIndex is None, the invisible root will be used (i.e. the complete forest will be expanded). """

        treeModel = self.model()
        if index is None:
            index = QtCore.QModelIndex()

        if index.isValid():
            self.setExpanded(index, expanded)

        for rowNr in range(treeModel.rowCount(index)):
            childIndex = treeModel.index(rowNr, 0, parentIndex=index)
            self.expandBranch(index=childIndex, expanded=expanded)