Stacks, Queues, and Trees