Don't infinitely recurse on cyclic path deps

Instead, keep a table of what we've visited and halt recursion whenever we
re-visit a package.