def smart_fqdn_exists(fqdn, *args, **kwargs):
    """
    Searching for a fqdn by actually looking at a fqdn is very inefficient.
    Instead we should:
        1) Look for a domain with the name of fqdn.
        2) Look for a label = fqdn.split('.')[0]
            and domain = fqdn.split('.')[1:]
    """
    # Try approach 1
    try:
        search_domain = mozdns.domain.models.Domain.objects.get(name=fqdn)
        label = ''
    except ObjectDoesNotExist:
        search_domain = None
    if search_domain:
        for type_, qset in _build_label_domain_queries(label, search_domain,
                                                       **kwargs):
            if qset.exists():
                return qset

    # Try approach 2
    search_domain = None
    if len(fqdn.split('.')) == 1:
        return None
    try:
        label = fqdn.split('.')[0]
        domain_name = '.'.join(fqdn.split('.')[1:])
        search_domain = mozdns.domain.models.Domain.objects.get(
            name=domain_name)
    except __HOLE__:
        search_domain = None
    if search_domain:
        for type_, qset in _build_label_domain_queries(label, search_domain,
                                                       **kwargs):
            if qset.exists():
                return qset
dataset/ETHPy150Open mozilla/inventory/mozdns/search_utils.py/smart_fqdn_exists