A way to kill an entity when its own kind is near by?

[1.20.1] Is there a way to have to kill an entity when its own kind is near (or share the same x & z values) to be killed?

Continue to help post