Comment #⁨3⁩

The problem with search operators such as the ones suggested, and with PARENT and GRANDPARENT, is that they are too fragile, searches that use them break as soon as you change something's indentation.

I'd like to see an ANCESTOR WITH TAG which took one argument (a tag) and matched the nearest ancestor node tagged with that tag. So in the original example

/- Level 1 #book
/-- Level 2 #chapter
/--- Level 3 #topic
/---- Level 4 #paragraph
/----- Level 5 #sentence

a search node nested under level 5 with the following query

ANCESTOR WITH TAG #chapter

would match the level 2 node.