private void shiftSegments(int fromIdx,int offset){
  for (  Element element : elements) {
    if (element.end.left > fromIdx) {
      shiftSegment(element.start,fromIdx,offset);
      shiftSegment(element.end,fromIdx,offset);
      if (element.text != null) {
        for (        Segment textSegment : element.text) {
          shiftSegment(textSegment,fromIdx,offset);
        }
      }
    }
  }
}

private void shiftSegments ( int fromIdx , int offset ) { for ( Element element : elements ) { if ( element . end . left > fromIdx ) { shiftSegment ( element . start , fromIdx , offset ) ; shiftSegment ( element . end , fromIdx , offset ) ; if ( element . text != null ) { for ( Segment textSegment : element . text ) { shiftSegment ( textSegment , fromIdx , offset ) ; } } } } }
iterates all existed elements and shifts their segments if needed
