In Mathematica, notebooks (in fact all expressions) have a tree-like structure. In this regard, they are similar to XML files. For XML, one can travel through the document structure using tools like XPath. What would be the equivalent in Mathematica so that beginning with
NotebookSelection one navigates towards the outermost
Notebook until one reaches a parent that matches certain pattern (say
Cell[__,”Input”,___]). If the pattern is reached, the selection is enlarged; otherwise, the selection stays the same.
To make the problem more interesting: is it possible to do it without changing the selection (the highlighted region should stay the same unless enlarged to avoid flickering) and without copying the notebook to a hidden one (the original notebook might be really large)?
Any pointers will be appreciated.