SOOOO I had an afternoon to kill (it's raining) and it seemed like a good exercise to learn more myself, and, well, I may have accidentally written my own version of what I think your trying to get at (attached).
I did start by trying to just replicate your code, but as soon as I thought about creating raycast nodes by hand in what I assumed was going to be 8 directions, I thought 'yehnah' and did it with code instead. Also, I assumed this was a button click type game and not a controllable character walking around, but the principal is the same I guess.
Then as testing with console prompts was getting laborious I added a next_pass effect onto the material to show which 'bombs' have been scanned... and before you know it, ended up like this:

Which looks like this when one is selected (and if you select a bomb, it does not count it in the total FYI):

Essentially if you have a grid of 'bomb's and click somewhere, it should tally all the bombs in the cardinal directions from that bomb by iterating a list of vectors to fire the raycast to. For each iteration it follows the same principal as your code, that it adds the object to an exception list and refires until there is nothing left.
If you wanted to you could use this method to tally up how many are in a given direction and not just the total, but felt like overkill.
I was going to setup an array system for generating the bombs but for the purpose of a one off I just duplicated/made unique. Also the next pass code is horrendously inefficient so you will notice a bit of lag between button clicks/highlighting but I can't be bothered to tidy it up (probably just need to generate the next pass material in advance rather than on the fly and use call_deferred to update it).... in fact in general just assume this is not a great way to do it, but it does work haha.
Let me know if you have any questions or this wasn't what you were aiming at. Learnt some new stuff about casting with code so I'm happy to help .
As a final sidenote, does anyone else use a massive ASCI art template for their code to make the mini sidebar thing more helpful?

You get that for free ;)