// pre: findLinesWidth carried out and elements sorted in ascending order
 public TextSegment getTopElementMatchingFontsizeAfterSorting() {
   TextSegment retVal = null;
   for (TextSegment s : items) {
     for (CompositeSegment<? extends TextSegment> l : foundLines) {
       if (l.getItems().contains(s)) {
         // if (s.getFontSize() == l.getFontSize())
         if (Utils.within(s.getFontSize(), l.getFontSize(), s.getFontSize() * 0.1f)) return s;
       }
     }
   }
   return retVal;
 }
 // pre: findLinesWidth carried out and elements sorted in ascending order
 public TextSegment getBottomElementMatchingFontsizeAfterSorting() {
   TextSegment retVal = null;
   for (int n = items.size() - 1; n >= 0; n--) {
     TextSegment s = items.get(n);
     for (CompositeSegment<? extends TextSegment> l : foundLines) {
       if (l.getItems().contains(s)) {
         // if (s.getFontSize() == l.getFontSize())
         if (Utils.within(s.getFontSize(), l.getFontSize(), s.getFontSize() * 0.1f)) return s;
       }
     }
   }
   return retVal;
 }