A relative optimal AST structure can be found from computing simplex with the derived constrains on the first AST parse + copy things over.
See also https://en.wikipedia.org/wiki/Simplex_algorithm. The general idea of non-recursive tree traversal is given here: https://stackoverflow.com/questions/28544980/data-oriented-tree-traversal-without-recursion/28616278#28616278.
I got the idea from user Prokop on discord, which was asking "is the adjacency of ast nodes in the node list used somehow to store information?".
A relative optimal AST structure can be found from computing simplex with the derived constrains on the first AST parse + copy things over.
See also https://en.wikipedia.org/wiki/Simplex_algorithm. The general idea of non-recursive tree traversal is given here: https://stackoverflow.com/questions/28544980/data-oriented-tree-traversal-without-recursion/28616278#28616278.
I got the idea from user Prokop on discord, which was asking "is the adjacency of ast nodes in the node list used somehow to store information?".