Get the index for the given TreeItem

        :param item: the treeitem to query
        :type item: :class:`TreeItem`
        :returns: the index of the item
        :rtype: :class:`QtCore.QModelIndex`
        :raises: ValueError

def index_of_item(self, item):
        """Get the index for the given TreeItem

        :param item: the treeitem to query
        :type item: :class:`TreeItem`
        :returns: the index of the item
        :rtype: :class:`QtCore.QModelIndex`
        :raises: ValueError
        """
        # root has an invalid index
        if item == self._root:
            return QtCore.QModelIndex()
        # find all parents to get their index
        parents = [item]
        i = item
        while True:
            parent = i.parent()
            # break if parent is root because we got all parents we need
            if parent == self._root:
                break
            if parent is None:
                # No new parent but last parent wasn't root!
                # This means that the item was not in the model!
                return QtCore.QModelIndex()
            # a new parent was found and we are still not at root
            # search further until we get to root
            i = parent
            parents.append(parent)

        # get the parent indexes until
        index = QtCore.QModelIndex()
        for treeitem in reversed(parents):
            parent = treeitem.parent()
            row = parent.childItems.index(treeitem)
            index = self.index(row, 0, index)
        return index