<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_prefix(self, ns_uri, prefix, set_as_preferred=False):
 """Adds prefix for the given namespace URI. The namespace must already exist in this set. If set_as_preferred is True, also set this namespace as the preferred one. ``prefix`` must be non-None; a default preference can't be set this way. See :meth:`set_preferred_prefix_for_namespace` for that. Args: ns_uri (str):
 The namespace URI to add the prefix to prefix (str):
 The prefix to add (not None) set_as_preferred (bool):
 Whether to set the new prefix as preferred Raises: NamespaceNotFoundError: If namespace ``ns_uri`` isn't in this set """

        assert prefix

        ni = self.__lookup_uri(ns_uri)

        self.__check_prefix_conflict(ni, prefix)
        ni.prefixes.add(prefix)
        self.__prefix_map[prefix] = ni

        if set_as_preferred:
            ni.preferred_prefix = prefix