Is there a method for AstNodes that checks if a certain line has a certain type of Token?

I’m trying to write a rule for a state table that detects if we jump to a non-existing state-line.

Say line 150 says to jump to line 151. Is there a way to check that my root rule has a token of type “STATE_LINE” at line 151 ?

Thanks in advance,

Rémi