public int overlapEnd(int start, int end) {
        if (start >= end) throw new IllegalArgumentException("The end " + end + " should be greater than start " + start);

        IntervalNode intervalNode = root;
        if (root == null || start >= root.maxEnd || end <= root.start)
            return -1;

        while (intervalNode != null) {
            if (intersection(start, end, intervalNode.start, intervalNode.end))
                return intervalNode.end;

            if (goLeft(start, end, intervalNode.left)) {
                intervalNode = intervalNode.left;
            } else {
                intervalNode = intervalNode.right;
            }
        }
        return -1;
    }