'Find the closest domain with an SOA record for a given domain name.
:param str domain_name: The domain name for which to find the closest SOA record.
:returns: The domain, if found.
:rtype: str
:raises certbot.errors.PluginError: if no SOA record can be found.'

def _find_domain(self, domain_name):

    domain_name_guesses = dns_common.base_domain_name_guesses(domain_name)
    for guess in domain_name_guesses:
        if self._query_soa(guess):
            return guess
    raise errors.PluginError('Unable    to    determine    base    domain    for    {0}    using    names:    {1}.'.format(domain_name, domain_name_guesses))
