>"The routine could maintain a path from root pointer to object (easily done on the recursion stack) so that it's reported along with matches."
Yes, it definitely could!
For extra points (if the additional functionality is desired!), also create an API interface for this functionality for coding AI's, present and future, such that they can also perform this form of grepping automatically when needed, for example, when running/debugging a program they wrote, or are assisting a programmer with making changes to...
(Observation: There seem to emerge two different main patterns with respect to variable inspection... One is to set a watchpoint on a variable and stop the program when the variable changes.
Another would be to globally scan all variables (i.e. grep) at specific intervals (a form of a batch pattern) for specific strings/values, and all of that would be/could be -- settable by the programmer and/or an AI...)
Anyway, your idea is a good one!