Hello Porunov,
First of all thank you very much for your response. I would like to give you more details to see if you can help me with this case.
I have a graph with all the data stored as follows:

As you can see in this image, you can see that I have a main node root, and from there we will have a tree structure with GROUPS - OUTLIERS. From a group can hang other groups or RESULT nodes, and the same for outliers. The results are the only nodes which we can be certain that will be a leaf node. So here we have an unknown size tree, and the point is to recover all this data and map it to a java object. (This graphs won't be really big, so storing them as a java object should not be an issue thinking in terms of memory).
Right now I'm exploring the tree() step to see if I can do something with it. How would you solve this situation?
Thanks in advance!
Cheers,
Adrian