Graphs bootcamp doubt


My doubt is in Graphs boot camp, there is a question on teams A and B as follows :

Suppose you were given a list of the outcomes of matches between pairs of teams, with each outcome being a win or loss. A natural question is as follows: given teams A and B, is there a sequence of teams starting with A and ending with B such that each team in the sequence has beaten the next team in the sequence?

In the code, there is elif curr in visited . I am confused what is this check for? I thought initially it was cycles but for cycles you need 3 colors or you need add to path and remove later. Doubt: what is this check elif curr in visited doing