radix translated from https://github.com/ngaut/radix