code: public function onPreDelete(ResourceEventInterface $event)
      {
          $address = $this->getAddressFromEvent($event);
  
          if (null === $customer = $address->getCustomer()) {
              return;
          }
  
          if ($address->isInvoiceDefault()) {
              if (!($customer->hasParent() && null !== $customer->getParent()->getDefaultInvoiceAddress())) {
                  throw new IllegalOperationException(); // TODO reason message
              }
          } elseif ($address->isDeliveryDefault()) {
              if (!($customer->hasParent() && null !== $customer->getParent()->getDefaultDeliveryAddress())) {
                  throw new IllegalOperationException(); // TODO reason message
              }
          }
      }
docs: Pre delete event handler.
  
  @param ResourceEventInterface $event
  
  @throws IllegalOperationException