You can group nodes.
Let’s say an enemy scene. Clicking on the root node of that scene, you can click on the Node tab.
Add a group name like “mobs” and in your code you can refer to this groups like this:
Example:
func _on_body_entered(body):
if body.is_in_group("mobs"):
body.get_hit(damage)
else:
# ignore