def METHOD_NAME(self, obj):
    assert isinstance(obj, ASTObject)
    assert not isinstance(obj, Reference)
    assert len(self.scopes) > 0
    if not hasattr(obj, 'name') or obj.name is None:
        return
    scope_type = type(obj)
    if scope_type in [Group, Instance]:
        scope_type = "group/component"
    else:
        scope_type = type(obj).__name__
    duplicate = self.scopes[-1][obj.name].get(scope_type)
    if duplicate is not None:
        raise ParseError('duplicate definition of %s \'%s\'; previous '
            'definition was at %s:%s' % (scope_type, obj.name,
            duplicate.filename or '<unnamed>', duplicate.lineno),
            obj.location)
    self.scopes[-1][obj.name][scope_type] = obj