Have you looked into stable-trie by @timo?
There are other packages as well, maybe Motoko-hashtable is a good fit as well?