separate Index::write and Index::write_tree