def METHOD_NAME(self, parent=QModelIndex()):
    if not parent.isValid():
        return len(self._data)
    key = parent.internalPointer()
    if key is not None:
        # child item
        return 0
    key = self._keys[parent.row()]
    return len(self._data[key])