RED.nodes.getAllFlowNodes is a client side thing not server side.
Do you mean on a tab or all nodes connected upstream and downstream by wires? Does that also include nodes connected indirectly (e.g link-in ~ link-out, link-call ~ link-in),
For me the solution is to read the "start"-file in the .node-red directory. All flows has the type "tab" and an id. The nodes whiche are also inside the "start" file - have a reference (property "z") to the Flow-IDs.
If you'll find the connection and so the "wires" reference to the following node(s) of a node. This ways for me works and seems to be the best.