Query challenge

Consider the following nodes with relationship [top_of]:


input will be a list of nodes like [n1,n3,n5]. In output, a node x from list will be removed if there is a path from another node y in the list to x. for example, because (n1)-[]->(n3) and (n1)-[]->(n5), n3 and n5 will be removed from the list and the output is [n5]

another example:
input: [n1,n4]
output: [n1,n4]