in reply to Help with node discovering and processing

Am I right to understand that you only need a "logical clock", i.e. some form of counter telling you in which order the various elements were accessed, but that you don't care about absolute time stamps?

If so, I would just declare a global counter to be incremented whenever you need. I think that this is a case where a global variable makes sense. If you really don't want a global variable, then you could use a closure maintaining that counter private to it and either doing the print job or returning the value of the (incremented) counter on demand. But it sounds a bit as overkill in the case.

Edit: Thinking about it, using a static variable (the relatively new state keyword), for example within a callback function, might be another way to go.