code: public static Span[] dropOverlappingSpans(final Span[] spans) {
  
      final List<Span> sortedSpans = new ArrayList<Span>(spans.length);
      Collections.addAll(sortedSpans, spans);
      Collections.sort(sortedSpans);
  
      final Iterator<Span> it = sortedSpans.iterator();
      Span lastSpan = null;
      while (it.hasNext()) {
        Span span = it.next();
  
        if (lastSpan != null) {
          if (lastSpan.intersects(span)) {
            it.remove();
            span = lastSpan;
          }
        }
        lastSpan = span;
      }
      return sortedSpans.toArray(new Span[sortedSpans.size()]);
    }
docs: Removes spans with are intersecting or crossing in anyway.
  
  <p>
  The following rules are used to remove the spans:<br>
  Identical spans: The first span in the array after sorting it remains<br>
  Intersecting spans: The first span after sorting remains<br>
  Contained spans: All spans which are contained by another are removed<br>
  
  @param spans
  the spans
  
  @return non-overlapping spans