def _get_zone_name(domain):
    """
    Get most specific matching zone for the given domain and return as a String

    :param domain: FQDN
    :return: FQDN of domain
    """
    zones = get_zones()
    zone_name = ""
    for zone in zones:
        if domain.endswith("." + zone) or domain == zone:
            if zone.count(".") > zone_name.count("."):
                zone_name = zone
    if not zone_name:
        function = inspect.currentframe().f_code.co_name
        log_data = {
            "function": function,
            "fqdn": domain,
            "message": "No NS1 zone name found.",
        }
        current_app.logger.debug(log_data)
        metrics.send(f"{function}.fail", "counter", 1)
    return zone_name

    Get most specific matching zone for the given domain and return as a String

    :param domain: FQDN
    :return: FQDN of domain
    
lemur/plugins/lemur_acme/nsone.py