pub fn new(
        db: &'a DB,
        hasher: &'a dyn HashTree,
        version: u64,
        create_new_version: bool,
    ) -> Self {
        let mut manifest = db.manifest().unwrap_or_default();
        if manifest.tags.is_none() {
            manifest.tags = Some(TreeTags::new(hasher));
        }
        manifest.version_count = version + 1;

        let base_version = if create_new_version {
            version.checked_sub(1)
        } else {
            Some(version)
        };
        let root = if let Some(base_version) = base_version {
            db.root(base_version).unwrap_or(Root::Empty)
        } else {
            Root::Empty
        };

        Self {
            db,
            hasher,
            manifest,
            leaf_count: root.leaf_count(),
            operation: if create_new_version {
                Operation::Insert
            } else {
                Operation::Update
            },
            updater: TreeUpdater::new(version, root),
        }
    }
Creates storage for a new version of the tree.
core/lib/merkle_tree/src/storage/mod.rs