def __check_prefix_conflict(self, existing_ni_or_ns_uri, incoming_prefix):
        """If existing_ni_or_ns_uri is a _NamespaceInfo object (which must
        be in this set), then caller wants to map incoming_prefix to that
        namespace.  This function verifies that the prefix isn't already mapped
        to a different namespace URI.  If it is, an exception is raised.

        Otherwise, existing_ni_or_ns_uri is treated as a string namespace URI
        which must not already exist in this set.  Caller wants to map
        incoming_prefix to that URI.  If incoming_prefix maps to anything
        already, that represents a prefix conflict and an exception is raised.
        """
        if incoming_prefix not in self.__prefix_map:
            return

        # Prefix found in the prefix map. Check that there are no conflicts
        prefix_check_ni = self.__prefix_map[incoming_prefix]

        if isinstance(existing_ni_or_ns_uri, _NamespaceInfo):
            existing_ni = existing_ni_or_ns_uri  # makes following code clearer?

            if prefix_check_ni is not existing_ni:
                # A different obj implies a different namespace URI is
                # already assigned to the prefix.
                raise DuplicatePrefixError(incoming_prefix, prefix_check_ni.uri, existing_ni.uri)
        else:
            ns_uri = existing_ni_or_ns_uri  # makes following code clearer?
            assert not self.contains_namespace(ns_uri)  # TODO (bworrell): Should this be a raise?
            raise DuplicatePrefixError(incoming_prefix, prefix_check_ni.uri, ns_uri)