What is the best way to avoid using goto statements in the pesudocode for an algorithm?
In many cases, GOTO statement can be replaced by loops. For example, in your case, the inner loop is just "while string(i) = path(j), decrease both i and j", and the outer loop is a "loop forever", also known by the C idiom "while true".