public boolean overlaps(SpanNode o) {
        int from = getFrom();
        int otherFrom = o.getFrom();
        int to = getTo();
        int otherTo = o.getTo();

        //is other from within our range, or vice versa?
        if ((otherFrom >= from && otherFrom < to)
            || (from >= otherFrom && from < otherTo)) {
            return true;
        }

        //is other to within our range, or vice versa?
        if ((otherTo > from && otherTo <= to)
            || (to > otherFrom && to <= otherTo)) {
            return true;
        }
        return false;
    }
Checks if the text covered by this span overlaps with the text covered by another span.

@param o the other SpanNode to check
@return true if spans are overlapping, false otherwise
document/src/main/java/com/yahoo/document/annotation/SpanNode.java