all the workings are a flattened recursion:
51 while len(indices):
it's a while loop. everything's in it.
looping on the length of the indices means it runs so long as more
data is queued.
data is pushed to the indices to process it next. this happens a few
lines down. the line numbers of the while loop and everything else are
changed because i added comments.
61 # after appending, it is not processing correct region
62 print('adding', ditem)
63 indices.append((ditem,
index_offset_in_stream, index_substart, index_subsize))
64 break
when it appends to the indices, it is providing more data to process,
that continues the loop.
i'm using a python quirk to manage popping off the indices so the data
gets used up. the 'break' statement terminates the loop over the
children in a way that doesn't engage an 'else' clause at the end of
it.
here's where they're popped:
79 else:
80 print('popping')
81 indices.pop()
here's where the children of the node are iterated:
53 index, index_offset, index_start, index_size = indices[-1]
54 index_offset_in_stream = index_offset - index_start
55 for type, index, index_substart, index_subsize, *_ in index:
the iteration happens right at the start of the overall wrapping while loop.
inside the iteration, it conditions on the child offset and the node type.