private static ExecutionSemester getBeginExecutionSemester( final DegreeCurricularPlan dcp, final RootCourseGroup root) { final Optional<Context> first = root.getChildContextsSet() .stream() .sorted( (o1, o2) -> o1.getBeginExecutionPeriod().compareTo(o2.getBeginExecutionPeriod())) .findFirst(); final ExecutionSemester result = first.isPresent() ? first.get().getBeginExecutionPeriod() : dcp.getFirstExecutionPeriodEnrolments(); return result; }