Implement a function that checks if an (reference) entity exists for a country/territory defined by its ISO code
One of the first steps of a Finalizer run is to delete all entities of the country/territory that Finalizer is processing. Due to the big size of the database, the query analysis of the database often leads to a sequential scan through the tiles. The problem lies in the fact that the search criterion is applied to the tiles which are then joined with entities to delete the latter. Therefore, it can save a lot of time if Finalizer can first check if any entity exists for the given country/territory and skip the deletion procedure if no entity has been found.
This function should provide an option to apply this search on entities and baseline entities.