Reimplements the :meth:`QAbstractItemModel.parent` method.

        :param index: Index.
        :type index: QModelIndex
        :return: Parent.
        :rtype: QModelIndex

def parent(self, index):
        """
        Reimplements the :meth:`QAbstractItemModel.parent` method.

        :param index: Index.
        :type index: QModelIndex
        :return: Parent.
        :rtype: QModelIndex
        """

        if not index.isValid():
            return QModelIndex()

        node = self.get_node(index)
        parent_node = node.parent
        if not parent_node:
            return QModelIndex()

        if parent_node == self.__root_node:
            return QModelIndex()

        row = parent_node.row()
        return self.createIndex(row, 0, parent_node) if row is not None else QModelIndex()