Traverses a tree. Invokes a callback on each node with the key, value, and current path.