Compact Prefix Tree in JavaScript