def _insert_item(self, key, new_item, instance, is_after):
        """Insert a new item before or after another item"""
        index = self._get_index_for_insert(key, instance)
        index = index + 1 if is_after else index
        self.__items = self.__items[:index] + new_item + self.__items[index:]
        # Make sure indexing works with new items
        for new_key, new_value in new_item:
            if new_key in self:
                value_list = [val for k, val in self.__items if k == new_key]
                dict_setitem(self, new_key, value_list)
            else:
                dict_setitem(self, new_key, [new_value])
Insert a new item before or after another item