Fixes issue #163.
We had to break up the resolution cycle when a NamedElement does not
have a name and we try to match one of its references, which may be the
item being resolved. This is the case when looking things up in own
package.