DependencyGraph: Don't choke on recursive import.
* Fixed #853.
* Added unit test.
Code: Null checks.