title: java lambda - how to traverse optional list/stream of optionals
body: <p>Having an Optional List of Optional's like:</p>
  
  <pre><code>Optional&lt;List&lt;Optional&lt;String&gt;&gt;&gt; optionalList = Optional.of(
      Arrays.asList(
          Optional.empty(),
          Optional.of("ONE"),
          Optional.of("TWO")));
  </code></pre>
  
  <p>How to traverse <code>optionalList</code> to print out the string's <code>ONE</code> and <code>TWO</code> ?</p>
  
  <p>What about having an Optional Stream of Optionals?</p>
  
  <pre><code>Optional&lt;Stream&lt;Optional&lt;String&gt;&gt;&gt; optionalStream = Optional.of(
      Stream.of(
          Optional.empty(),
          Optional.of("ONE"),
          Optional.of("TWO")));
  </code></pre>
  
  <p>Update: Thanks for answers, solution for optionalStream (non nested):</p>
  
  <pre><code>optionalStream
      .orElseGet(Stream::empty)
      .filter(Optional::isPresent)
      .map(Optional::get)
      .forEach(System.out::println);
  </code></pre>