fix Issue 9865 - Crash on bogus import / circular reference
Merge pull request #1835 from 9rnsr/fix9865

[REG2.062] Issue 9865 - Crash on bogus import / circular reference