In theory, there might be a situation in which the loop is longer. For example, ["L1", "S21", "L21", "S22", "L22", "S23", "L23", "S24", "L1"].
The student may have skill S22 (obtained through another lesson L99), so he should be able to follow route ["L99", "S22", "L22", "S23", "L23", "S24", "L1"] to the required lesson (the skill that this lesson provides). And we are depriving him of this opportunity.
PS: I understand that it looks strange. But people sometimes do illogical things. Even teachers creating lessons.
match (a:Lesson)-[:REQUIRES]->(b:Skill)
with distinct a.id as lesson, collect(distinct b.id) as skls
match (c:Skill)-[:PROVIDED_BY]->(d:Lesson)
where c.id in skls
with lesson, skls, collect(distinct d.id) as lessons
return lesson as Lesson, apoc.coll.sort(skls) as requiredSkills, apoc.coll.sort(lessons) as lessonsProvideSkills, size(lessons) as totalLessons order by totalLessons desc