// Get only one node by querying the database for entities
// matching conditions (catalog item nodes using tid).
$result=$nodeStorage->getQuery()
->condition('type','uw_ct_catalog_item')
->condition('field_uw_catalog_catalog',$tid)
->pager(1)
->execute();
// If the result isn't empty, we have a match.
if(!empty($result)){
// Warn the user.
\Drupal::messenger()->addWarning(t('You cannot delete this catalog as it is in use. Delete or reassign any catalog items assigned to this catalog in order to be able to remove it.'));