They make the code harder to reason about and introduce invarients that could be violated.  For example, at line 48, you have to make sure to clear the "visited" otherwise things break.  Passing "visited" as a parameter prevents the problem of that invariant.