Split out a domain in its parents

    Leverages tldextract to take the TLDs from publicsuffix.org
    or makes a valiant approximation of that

    :param domain: dc2.ams2.example.com
    :param tld: Include TLD in list
    :return: [ 'dc2.ams2.example.com', 'ams2.example.com', 'example.com']

def _tree(domain, tld=False):
    '''
    Split out a domain in its parents

    Leverages tldextract to take the TLDs from publicsuffix.org
    or makes a valiant approximation of that

    :param domain: dc2.ams2.example.com
    :param tld: Include TLD in list
    :return: [ 'dc2.ams2.example.com', 'ams2.example.com', 'example.com']
    '''
    domain = domain.rstrip('.')
    assert '.' in domain, 'Provide a decent domain'

    if not tld:
        if HAS_TLDEXTRACT:
            tld = tldextract.extract(domain).suffix
        else:
            tld = re.search(r'((?:(?:ac|biz|com?|info|edu|gov|mil|name|net|n[oi]m|org)\.)?[^.]+)$', domain).group()
            log.info('Without tldextract, dns.util resolves the TLD of %s to %s',
                     domain, tld)

    res = [domain]
    while True:
        idx = domain.find('.')
        if idx < 0:
            break
        domain = domain[idx + 1:]
        if domain == tld:
            break
        res.append(domain)

    return res