<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def add_filter(self, name, filter):
        '''Adds a filter with the given name.

        ``filter`` must be the **class** object rather than
        an instance. The class *must* be a subclass of
        :class:`dossier.web.Filter`, which should provide a means
        of creating a predicate function.

        The ``filter`` must be a class so that its dependencies can be
        injected when the corresponding route is executed by the user.

        If ``filter`` is ``None``, then it removes a possibly existing
        filter named ``name``.

        :param str name: The name of the filter. This is how the search engine
                         is invoked via REST.
        :param engine: A filter *class*.
        :type engine: `type`
        :rtype: :class:`WebBuilder`
        '''
        if name is None:
            self.filters.pop(name, None)
        self.filters[name] = filter
        return self