Removes the given key/value from all elements.
        If value is not specified, the whole key is removed.
        If value is not None and the key is present but with a
        different value, or if the key is not present, silently passes.

def kremove(self, key, value=None):
        """Removes the given key/value from all elements.
        If value is not specified, the whole key is removed.
        If value is not None and the key is present but with a
        different value, or if the key is not present, silently passes.
        """
        for item in self:
            if value is None:
                # Just pop the key if present,
                # otherwise return None
                # (shortcut to ignore the exception)
                item.pop(key, None)
            else:
                try:
                    # Use the key as a set
                    item[key].remove(value)
                    # If the set contains a single element
                    # just store the latter
                    if len(item[key]) == 1:
                        item[key] = item[key].pop()
                except KeyError:
                    # This happens when the item
                    # does not contain the key
                    pass
                except AttributeError:
                    # This happens when the key is not a set
                    # and shall be removed only if values match
                    if item[key] == value:
                        item.pop(key)