Cool ideas.
You could check if it's the last or first node with "vdf_get_first_node" or vdf_get_last_node", but I see the advantages of using your model in a loop.
The new version is going to change functions arguments a bit, since nodes and trees will be pointers, functions like vdf_get_next_node won't need to pass the tree i.e.
And although this means performance enhancement you'll have to be very careful - I crashed hl a couple of times when I was writing the new example script carelessly...
For the same reason it's better to detach nodes concept from numbers. I'll include a function to count nodes in a branch though.
Finally I'm including important stuff I had forgotten like destroying trees and setting keys/values functions.