First of all you have to know that n8n does not advance the chain if no data is available.
To avoid this, there is this setting in the respective node:
Than you can use a function to check if items are empty with:
items.length == 1 && Object.keys(items[0].json).length == 0
Here a complete example: