Fix detection of already visited nodes in DependencyResolver. See #280.

Fixes a stack overflow for package graphs with cycles.
Detect dependency cycles after version resolution and before configuration resolution. Fixes #280.