identify "already visited" nodes, best approach?

is there a way to uniquely identify a SyntaxNode? i need to maintain a list of “already visited” syntaxnodes, and i don’t know how to identify them.

in other words: let’s assume every SyntaxNode has an “id” string-attribute that is different for every node in the tree. then i can just store the ids of nodes i already visited somewhere, so that next time i can skip that node while walking in the tree. but there is no such “id”… so, what is the best approach to achieve this?

i also looked at just storing the syntaxnodes itself, but it seems they are not guaranteed to be the same object always. (in other words, “n.parent.firstChild === n” does not hold for nodes with no siblings)

There’s no easy way to do this — it hasn’t really come up for me, since code usually tends to just visit the entire tree in order. If this is about caching results and it’s okay to have somewhat rougher granularity than single nodes, you could use a Set or Map on SyntaxNode.tree, which gives you the back Tree when the node doesn’t point into a TreeBuffer.