It is determined by iterating over the number of loops
X.12 in Tcl can be tricky since there can be loops within loops within loops, etc.,
The best way to tackle it is to use namespaces and children of namespaces.
A lot easier than back in the early days when I would do it with keyed lists sometimes nested 25 or more layers deep 🙁