optimize isOneToOne to only check one time per context.