Graph loop detection in Go using Tarjan's algorithm