Replace tree_nodes implementation, which was both complicated and wrong.

It failed to traverse all the op childs for LISTOPs, LOGOPs and PMOPs.
More fixes for tree traversal in fill_linkinfo().