Sort of - people do use Tinderbox to write or prepare books, but it is not a book-writing app so there in no one right way to do this. IOW, you are looking for a solution not the solution that your comment implies.
I’m real busy for next week and this is a large topic (can others step in?) but a few pointers. You’ve just surfaced an assumption: chapters contain zero or more sub-chapters (are there sub-sub-chapters?) so you should plan for a chapter prototype and a sub-chapter prototype† and keep them in the
/Prototypes container with the built-in prototypes‡. Now we can more easily see that a note, even in a sub-chapter will only have one ancestor note with the chapter-type prototype.
† Tip: when naming prototypes, use a prefix or suffix - one you like - such that prototype note $Name is no one you will use elsewhere. For instance ‘pChapter’ is unlikely to get used as a title for some other note.
‡ If you don’t yet have that container, add a built-in prototype from the File menu and Tinderbox will create it (you can always delete the newly added prototype if not wanted).
To set $Subtitle to the name of the ancestor note using a prototype called “pChapter”, try this as an edict (code not tested):
$MyList = find(ancestors);
Why an edict not a rule? You only really need to run this once and then occasionally in case the note moves. That is exactly what an edict does. A
find() task has to poll the whole document and as it grows, and each note is doing this task you can see it becomes a lot of unnedded constant checking.