Cypher match and return distinct nodes according to a parameter

Hello,
I have a simple query like this :

MATCH (n:application) RETURN n

and with a parameter 'app' in the node, so with this query for each application i have like 2 nodes with different ids but with the same parameter 'app'.

What i want is to get all applications nodes with distinct on 'app' param, in the case that i have two nodes i want one of them not the 2 returned.

Thank you,

you can try the following. It will query for all Application nodes, groups them by n.app values, then return only one node for each distinct value of n.app

MATCH (n:application)
with n.app, collect(n) as nodes
return n.app, nodes[0]