First running implementation of triestack (slow).
Slightly faster version.
Time reduced to 60% with 'add_all_children()'.