Query suggestion. Looking for notes with no children

The Scenario (TLDR; Looking for note (depth 5) with no children)
I like to use TaskPaper to keep track of events and their tasks while also planning for future events and tasks. I am in charge of coordinating every thing and also adding certain tasks. Right now I am just looking at things by date, but I want to be more proactive on my search. I would like to look for certain type of notes (They all start with the same word and are found at the same depth…) that have not children. Something like this.

Project:
    Sub-project:
        Sub-project:
            Sub-project:
                Note I don't want
                    - Task 1
                    - Task 2
                    - Task 3
        Sub-project:
            Sub-project:
                Note that I want
        Sub-project:
            Sub-project:
                Note I don't want
                    - Task 1
                    - Task 2
                    - Task 3

Any suggestions to only get the Note that I want?

It’s a bit messy but I think you could do it by:

  1. Find set of items that you want (ignoring children constraint) (group 1)
  2. Find set of items that you want that have children. Do this by adding /*/..* to the end of your original search (group 2)
  3. Then combine those those two groups with except

So for example this would find all items at level 2 that have no children:

/*/* except /*/*/*/..*

This is what I ended up using (adapting things to my example)

//Note except (//Note/*/..* union @done//*)