cache-tree: convert write_*_as_tree to object_id