def popitem(self):
        """Remove and return (key, value) pair.

        Raises KeyError if dict is empty. If not empty it
        also removes corresponding value(s) from the
        flat_values list accordingly.

        Extends dict.popitem.
        """
        ### execute the builtin dict.popitem method
        popped_item = super().popitem()

        ### remove value(s)

        ## retrieve value
        value = popped_item[1]

        ## remove the value(s) from the flat_values list
        ## depending on whether the value from the
        ## popped item is a mapping or not

        # if value is not a mapping, just remove it

        if not isinstance(value, Mapping):
            self._bound_remove(value)

        ## if otherwise it is a mapping, retrieve the
        ## nested values and remove one by one

        else:

            # get generator with all nested values
            nested_values = flatten_mapping_values(value)

            # remove one by one from the flat_values
            # list
            for nested_value in nested_values:
                self._bound_remove(nested_value)

        ### finally return the popped item
        return popped_item
Remove and return (key, value) pair.

        Raises KeyError if dict is empty. If not empty it
        also removes corresponding value(s) from the
        flat_values list accordingly.

        Extends dict.popitem.
        
nodezator/ourstdlibs/collections/fldict/main.py