Fix bugs in erase.

Removing keys that are a prefix of another key in the tree ("prefix"
meaning the non-null-terminated version of the key-to-remove fully
prefixes another) had problems with sometimes removing branches that are
still valid.