Returns the IP as an `IPAddress` object (if packed bytes are defined).

def AsIPAddr(self):
    """Returns the IP as an `IPAddress` object (if packed bytes are defined)."""
    if self.packed_bytes is None:
      return None

    packed_bytes = self.packed_bytes.AsBytes()

    if self.address_type == NetworkAddress.Family.INET:
      return ipaddress.IPv4Address(packed_bytes)
    if self.address_type == NetworkAddress.Family.INET6:
      return ipaddress.IPv6Address(packed_bytes)

    message = "IP address has invalid type: {}".format(self.address_type)
    raise ValueError(message)