Implementation with php of the a left-right tree traversal algorithm