There are probably several places in the kvTrie and bwTrie methods which can have one or more of the following improve performance:
- Early return/continue conditions
- Avoid multiple len() counts on the same string/byte data
- Better commenting about states considered when comparing keys