Dear M-A,
If I understand correctly you want to get at the value (not the key) of what you're clicking on. Please see and example stack (can be modified if you want to show the last key instead, but I'll leave that as an exercise to you
). I on purpose have included a separator in the tree widget of this stack to make it clear what is a key and what is a value, as it can be misleading.
There might be a better way of doing this - but what I'm doing is building a string with the array keys (array[lvl1][lvl2][lvl3] for example) and making it into a command by putting in into a
do merge() (note that the contents of do merge should all be text; if an expression needs to be evaluated inside this (eg 1+1) then enclose this in double square brackets).
I also attach a stack which I created for a completely different discussion but shows how to do some other manipulations with the tree widget, like collapse/expand all etc. I haven't looked at the code in this in a long time, but since it works, I attach this as well..