Tree depth

same of the kvs implementation