Okay, I'm looking further. It seems from the level code that maybe if you go over the limit for the short 7 bit key plus the leading zero, you get a 31 bit key, plus the leading one.
So the tcl code I wrote would break pretty quickly in normal use. But will every installation start out at the same level? Maybe not? I might need to get the level for the root of my tree first.