Follow-up of cosmos/cosmos-sdk#2131.
After discussion on Slack, a suggestion to implement a fix:
- For each new node in IAVL tree, assign an sequential integer ID. This ID never changes for the node.
- Use this integer ID as "key" in the <key, value> pair stored in LevelDB.
- The value part stored in LevelDB contains the node hash (existing LevelDB key).
- All parent/child references must be through integer IDs.
- A special "root" key stored in LevelDB has an value that contains the integer ID of the root node.