Some tree first implementation.