private void addRoute(NodeBuilder<V> node, Entry<V> entry) {
        String path = entry.path;
        NodeBuilder<V> current = node;
        while (true) {
            final String p = current.path;
            final int max = Math.min(p.length(), path.length());

            // Count the number of characters having the same prefix.
            int same = 0;
            final PathReader pathReader = new PathReader(path);
            while (same < max && pathReader.isSameChar(p.charAt(same))) {
                same++;
                pathReader.moveIndex();
            }

            // We need to split the current node into two in order to ensure that this node has the
            // same part of the path. Assume that the path is "/abb" and this node is "/abc/d".
            // This node would be split into "/ab" as a parent and "c/d" as a child.
            if (same < p.length()) {
                current.split(same);
            }

            // If the same part is the last part of the path, we need to add the value to this node.
            if (same == path.length()) {
                current.addValue(entry.value, entry.hasHighPrecedence, comparator);
                return;
            }

            // We need to find a child to be able to consume the next character of the path, or need to
            // make a new sub trie to manage remaining part of the path.
            final NodeBuilder<V> next = current.child(pathReader.peekAsKey());
            if (next == null) {
                // Insert node.
                insertChild(current, pathReader.remaining(), entry.value, entry.hasHighPrecedence);
                return;
            }

            current = next;
            path = pathReader.remaining();
        }
    }
Adds a new route to the trie.
core/src/main/java/com/linecorp/armeria/server/RoutingTrieBuilder.java