Check if the field contains the id, including the local id. If you need to exclude the local value, use instead:
id in field.withoutSelf().keys