Couple of suggestions.
What you're trying to do is implement a 'control system' using a Node-RED flow.
So the first thing to do is work out a specification or algorithm that defines what should happen under certain conditions. You probably have this already on your piece of paper. Having a good 'spec' also means you can create a testbench to prove the system works under all conditions.
For a very basic control system it normally means... "when I have these inputs then create this output".
Just like having a logic gate to detect an input and produce an output.
In your situation you are dealing with a non-trivial control system that has 'states' as well as 'inputs', so the complexity increases. For example detecting if there is a train within a block, about to leave a block or whether the block is empty will affect the track-side signals.
Many real-life (control) situations like getting money out of a cash machine are really a simple state machine. You have to do things in a certain sequence in order to get to the final result and sometimes there may be more than one path to get to a certain point.
I'm a big fan of finite state machines (FSMs) as it's usually a fairly easy task to construct a (graphical) state diagram to show how you can navigate from one state to another. Once the state diagram is complete and providing there are no dead-ends or unreachable states - you can code it.
Which language you use to do this is up to you, but since we are talking about Node-RED then JavaScript is probably the best choice.
If you want to see a simple example of a FSM then have a look at the Mathematical Magic Machine, I published on Discourse over Christmas. Hope you find this useful.