I hope this snippet of query can help you:
with obj.Id as keyName
where n[keyName] is not null
with n,keyName,n[keyName] as value
with apoc.map.fromPairs([[keyName,value]]) as ns
To accomplish this I've to create a temporarily CHILD relation.
Didn't find any apoc that can create a virtual paths from nodes. Which would be a better solution.
To rerun the solution you have to delete the child relations at the beginning ohterwise...
To begin with you could try this procedure:
Neo4j Graph Database Platform
apoc.convert.toTree - APOC Documentation
This section contains reference documentation for the apoc.convert.toTree procedure.