code: protected function hasNotification(SaleInterface $sale, $type, $number)
      {
          foreach ($sale->getNotifications() as $n) {
              if ($n->getType() !== $type) {
                  continue;
              }
  
              if ($n->hasData('shipment') && $n->getData('shipment') === $number) {
                  return true;
              }
          }
  
          return false;
      }
docs: Returns whether the sae has a notification with the given type and shipment number.
  
  @param SaleInterface $sale
  @param               $type
  @param               $number
  
  @return bool