Set<Interval> intervals = new HashSet<Interval>();
for (LessonInstance instance : getLessonInstancesSet()) {
intervals.add(new Interval(instance.getBeginDateTime(), instance.getEndDateTime()));
}
if (!wasFinished()) {
YearMonthDay startDateToSearch = getLessonStartDay();
YearMonthDay endDateToSearch = getLessonEndDay();
for (YearMonthDay day : getAllValidLessonDatesWithoutInstancesDates(startDateToSearch, endDateToSearch)) {
intervals.add(new Interval(day.toLocalDate().toDateTime(
new LocalTime(getBeginHourMinuteSecond().getHour(), getBeginHourMinuteSecond().getMinuteOfHour(),
getBeginHourMinuteSecond().getSecondOfMinute())), day.toLocalDate().toDateTime(
new LocalTime(getEndHourMinuteSecond().getHour(), getEndHourMinuteSecond().getMinuteOfHour(),