How to only return the msg with the highest payload parameter (wait and filter)

Good day,

I have a function node that loops through an array and outputs 4 distinct messages via 4 different outputs. Each message has a unique indicator, i.e. 1m, 5m, 15m, 1hr.

Under certain circumstances, the node may output multiple msgs within a very short amount of time (less than a few seconds), because multiple criteria have been met.

I'd like to somehow wait after the first message is received, to see if other messages arrive, example:

1m is sent, wait to see if 5m, 15m, or 1 hr also arrive within a few seconds, if so, only send on the highest value, if not, return the original msg (in this case 1m).

How can I best achieve this?

Many thanks in advance.

P.S. My ideal scenario would be to state that criteria x and x and x was met, but I'm not sure if this is possible!

push the positive result into an array.

Then do the analysis on the array before sending anything

So in essence, push all messages to an array and then analyse the array to see which has the highest value, then send it? Logical and very simple, thanks!