Tree implementation.