Refactoring: only find the topmost class when doing rid, not uuid, because for uuids it’s not needed.