@staticmethod
def _prefixize_uri_if_possible(uri, namespaces_dict):
    """
        It returns None it it doesnt find an adequate prefix

        :param uri:
        :param namespaces_dict:
        :return:
        """
    best_match = None
    for a_namespace in namespaces_dict:
        if uri.startswith(a_namespace):
            if best_match is None or len(best_match) < len(a_namespace):
                best_match = a_namespace
    return None if best_match is None else uri.replace(best_match, 
        namespaces_dict[best_match] + ':')
