Scala 3, Programming Scala.
optional defines the boundary, which will hopefully see a Some[Seq[T]] returned or, worst case, a None. We map over the input sequence and for each nested sequence, we get the headOption, but then immediately extract the element using the new extension method ?. The map iteration will continue as