title: Generic nested Options pattern matching
body: <p>I have this data structures with case class in an option and the field being wrapped in an option as well:</p>
  
  <pre><code>case class Name(value: Option[String]) extends AnyVal
  case class Data(id: Int, name: Option[Name], isDefault: Boolean)
  </code></pre>
  
  <p>So I would like to handle cases when there is some for the Name, the same goes for upper Option. But when there is None for the Name I would like to have <code>None</code> as the result instead of <code>Some(Name(None))</code>.
  I tried to do something like this: </p>
  
  <pre><code>def handleNestedOptions(value: Option[String]): Option[Name] = {
    value match {
      case Some(data) =&gt; Some(Name(Some(data)))
      case None =&gt; None
    }
  }
  </code></pre>
  
  <p>But I also would like to have it in a generic way so it could work for any case class of the same structure I have. So how can I change this implementation to make it more generic?
  By generic I mean something like this:
  <code>def handleNestedOptions[T, K](value: Option[K]): Option[T]</code></p>