code: def from_xfr(xfr, zone_factory=Zone, relativize=True):
      
  
      z = None
      for r in xfr:
          if z is None:
              if relativize:
                  origin = r.origin
              else:
                  origin = r.answer[0].name
              rdclass = r.answer[0].rdclass
              z = zone_factory(origin, rdclass, relativize=relativize)
          for rrset in r.answer:
              znode = z.nodes.get(rrset.name)
              if not znode:
                  znode = z.node_factory()
                  z.nodes[rrset.name] = znode
              zrds = znode.find_rdataset(rrset.rdclass, rrset.rdtype,
                                         rrset.covers, True)
              zrds.update_ttl(rrset.ttl)
              for rd in rrset:
                  rd.choose_relativity(z.origin, relativize)
                  zrds.add(rd)
      z.check_origin()
      return z
docs: Convert the output of a zone transfer generator into a zone object.
  
      @param xfr: The xfr generator
      @type xfr: generator of dns.message.Message objects
      @param relativize: should names be relativized?  The default is True.
      It is essential that the relativize setting matches the one specified
      to dns.query.xfr().
      @type relativize: bool
      @raises dns.zone.NoSOA: No SOA RR was found at the zone origin
      @raises dns.zone.NoNS: No NS RRset was found at the zone origin
      @rtype: dns.zone.Zone object