void (@NotNull TreeElement firstNew) { TreeElement anchorPrev = getTreePrev(); if(anchorPrev == null){ firstNew.rawRemoveUpToLast(); CompositeElement p = getTreeParent(); if(p != null) p.setFirstChildNode(firstNew); while(true){ TreeElement treeNext = firstNew.getTreeNext(); assert treeNext != this : "Attempt to create cycle"; firstNew.setTreeParent(p); if(treeNext == null) break; firstNew = treeNext; } setTreePrev(firstNew); firstNew.setTreeNext(this); if (p != null) { p.subtreeChanged(); } } else anchorPrev.rawInsertAfterMe(firstNew); DebugUtil.checkTreeStructure(this); }