public void addChild(final @NotNull ElementNode childNode) {
    final int last = this.children.size() - 1;
    if (!(childNode instanceof TextNode) || this.children.isEmpty() || !(this.children.get(last) instanceof TextNode)) {
      this.children.add(childNode);
    } else {
      final TextNode lastNode = (TextNode) this.children.remove(last);
      if (lastNode.token().endIndex() == childNode.token().startIndex()) {
        final Token replace = new Token(lastNode.token().startIndex(), childNode.token().endIndex(), TokenType.TEXT);
        this.children.add(new TextNode(this, replace, lastNode.sourceMessage()));
      } else {
        // These nodes aren't adjacent in the string, so put the last one back
        this.children.add(lastNode);
        this.children.add(childNode);
      }
    }
  }
Adds a child to this node.

<p>This method will attempt to join text tokens together if possible.</p>

@param childNode the child node to add.
@since 4.10.0
text-minimessage/src/main/java/net/kyori/adventure/text/minimessage/internal/parser/node/ElementNode.java