def METHOD_NAME(self, index):
    """Return the category pointed to by the given index.
    Args:
        idx: A QModelIndex
    Returns:
        A category if the index points at one, else None
    """
    # items hold an index to the parent category in their internalPointer
    # categories have an empty internalPointer
    if index.isValid() and not index.internalPointer():
        return self._categories[index.row()]
    return None