'Find the deepest match to I{name} in the dictionary.
The deepest match is the longest name in the dictionary which is
a superdomain of I{name}.
@param name: the name
@type name: dns.name.Name object
@rtype: (key, value) tuple'

def get_deepest_match(self, name):

    depth = len(name)
    if (depth > self.max_depth):
        depth = self.max_depth
    for i in xrange((- depth), 0):
        n = dns.name.Name(name[i:])
        if self.has_key(n):
            return (n, self[n])
    v = self[dns.name.empty]
    return (dns.name.empty, v)
