Utilities for implementing a modified pre-order traversal tree in PHP