code: def zone_for_name(name, rdclass=dns.rdataclass.IN, tcp=False, resolver=None):
      
  
      if isinstance(name, basestring):
          name = dns.name.from_text(name, dns.name.root)
      if resolver is None:
          resolver = get_default_resolver()
      if not name.is_absolute():
          raise NotAbsolute(name)
      while 1:
          try:
              answer = resolver.query(name, dns.rdatatype.SOA, rdclass, tcp)
              if answer.rrset.name == name:
                  return name
              # otherwise we were CNAMEd or DNAMEd and need to look higher
          except (dns.resolver.NXDOMAIN, dns.resolver.NoAnswer):
              pass
          try:
              name = name.parent()
          except dns.name.NoParent:
              raise NoRootSOA
docs: Find the name of the zone which contains the specified name.
  
      @param name: the query name
      @type name: absolute dns.name.Name object or string
      @param rdclass: The query class
      @type rdclass: int
      @param tcp: use TCP to make the query (default is False).
      @type tcp: bool
      @param resolver: the resolver to use
      @type resolver: dns.resolver.Resolver object or None
      @rtype: dns.name.Name