Implementation in php of the left-right tree traversal algorithm