@Override
  public void addChild(@NotNull ASTNode child, @Nullable ASTNode anchorBefore) {
    LOG.assertTrue(anchorBefore == null || ((TreeElement)anchorBefore).getTreeParent() == this, "anchorBefore == null || anchorBefore.getTreeParent() == parent");
    TreeUtil.ensureParsed(getFirstChildNode());
    TreeUtil.ensureParsed(child);
    TreeElement last = ((TreeElement)child).getTreeNext();
    TreeElement first = (TreeElement)child;

    removeChildrenInner(first, last);

    ChangeUtil.prepareAndRunChangeAction(destinationTreeChange -> {
      if (anchorBefore != null) {
        insertBefore((TreeChangeEventImpl)destinationTreeChange, (TreeElement)anchorBefore, first);
      }
      else {
        add((TreeChangeEventImpl)destinationTreeChange, this, first);
      }
    }, this);
  }
@Override
  public void addChild(@NotNull ASTNode child, @Nullable ASTNode anchorBefore)