Refactored seqOptional to drop code duplication.