How to Make a Cascading List

Outlines (hierarchies) are recursively-defined data structures. If the length and depth of each level are fixed in advance, then it becomes possible to manually build it. (In some systems, this requires nominally different types of objects at each level.)

If they’re not known in advance, then you typically need to invent (or discover) two things:

  1. A specification of some kind, in machine-readable form, adequately describing the shape (and content) of the hierarchy in concrete terms.
  2. Program code, to read the specification, and dynamically build the corresponding hierarchy from instances of simpler pieces.

I took a stab at something like this with
Roll-your-own expanding/contracting outlines
You may be able to use some of the same principles and techniques.

There are other examples in the same Forum area. And now that we have ORDER BY in our database arsenal, there may be even better ways to specify the outline structure.