Add toString() function to TernaryTriePrimitive