private static void insert(final Token token, final Token value) {
    if (token.childTokens() == null) {
      token.childTokens(Collections.singletonList(value));
      return;
    }
    if (token.childTokens().size() == 1) {
      final ArrayList<Token> list = new ArrayList<>(3);
      list.add(token.childTokens().get(0));
      list.add(value);
      token.childTokens(list);
    } else {
      token.childTokens().add(value);
    }
  }
Optimized insert method for adding child tokens to the given {@code token}.

@param token The token to add {@code value} as a child.
@param value The token to add to {@code token}.
text-minimessage/src/main/java/net/kyori/adventure/text/minimessage/internal/parser/TokenParser.java