Ensure that the passed-in optimizer is a sequence.
Merged with me upstream master.