[NRefactory] Try to prevent infinite loop in type lookup.

Unfortunately I can't reproduce it - but I have a stack trace that shows it can happen.