As stated elsewhere, although I'm not specifically familiar with how the
internals of treeview procedures work, I have worked with data trees. One
way that I can think of is within the procedure that evaluates when selecting
a node, to look at the parent object recursively until at the top of the
tree. This assumes of course that one, each node has at least one parent,
two that the root of the tree can be consistently identified by some piece of
data, even if it is that the parent is null or something similar, and three
that the relationship(s) are not circular allowing the parent of a child to
be a child of the same child without addressing that circumstance..
Otherwise you would probably have to go through the entire list of nodes to
identify which one is active/selected. :\ Not a quick task.