Patricia tree implementation in JavaScript