Include depth in tree traversal callback