private static TreeElement findTopmostAnchor(@Nullable TreeElement anchorBefore) {
    while (anchorBefore != null && anchorBefore.getTreePrev() == null) {
      CompositeElement parent = anchorBefore.getTreeParent();
      if (parent.getTreeParent() == null) break;
      anchorBefore = parent;
    }
    return anchorBefore;
  }
private static TreeElement findTopmostAnchor(@Nullable TreeElement anchorBefore)