The script in your example returns only one alarm for each key. E.g. if you have several node with NODE_DOWN alarm, only one will be returned.
Can you give some information on what you are trying to achieve as the final result?
Can you give some information on what you are trying to achieve as the final result?