Fix callstack error when processing installed packages with circular deps. Fixes #1349