If you’re going to a set of related records in order to perform an action on those records, i.e., delete, them, you MUST first trap to see if there are actually related records to go to. If you don’t do this, the action that you were going to take will be performed on the table and records that the script started from with potentially disastrous consequences.