def METHOD_NAME(self, row, column, parent):
    if not self.hasIndex(row, column, parent):
        return QModelIndex()
    if parent.isValid():
        key = self._keys[parent.row()]
        return self.createIndex(row, column, key)
    return self.createIndex(row, column, None)