title: Filtering collection stream inside collection stream before returning
body: <h1>Background information</h1>
  
  <p>I've got the following classes:</p>
  
  <h3>Insurance</h3>
  
  <pre><code>public class Insurance {
      ...
  }
  </code></pre>
  
  <h3>Customer</h3>
  
  <pre><code>public class Customer {
      private List&lt;Insurance&gt; insurances;
  
      public List&lt;Insurance&gt; getInsurances() {
          return insurances;
      }
      ...
  }
  </code></pre>
  
  <h3>CustomerRegistry</h3>
  
  <pre><code>public class CustomerRegistry {
      private List&lt;Customer&gt; customers;
      ...
  }
  </code></pre>
  
  <p>as well as this helper method, which reduces a <code>List&lt;Predicate&lt;T&gt;&gt;</code> into a single <code>Predicate&lt;T&gt;</code>:</p>
  
  <pre><code>public Predicate&lt;T&gt; reducePredicates(List&lt;Predicate&lt;T&gt;&gt; predicates) {
      return predicates.stream()
                       .reduce(Predicate::and)
                       .orElse(p -&gt; true);
  }
  </code></pre>
  
  <hr>
  
  <h1>The problem</h1>
  
  <p>What I want to do is get a list of insurances that match a list of filters, belonging to customers that match a list of filters. If this is unclear, the below code will hopefully clarify.</p>
  
  <p><em>Method is inside <code>CustomerRegistry</code> class above.</em></p>
  
  <pre><code>public List&lt;Insurance&gt; findInsurances(List&lt;Predicate&lt;Customer&gt;&gt; cusPredicates,
  List&lt;Predicate&lt;Insurance&gt;&gt; insPredicates) {
  
      List&lt;Insurance&gt; matches = new LinkedList&lt;&gt;();
      customers.stream()
               .filter(reducePredicates(cusPredicates)
               .forEach(cus -&gt; cus.getInsurances()
                                 .stream()
                                 .filter(reducePredicates(insPredicates))
                                 .forEach(cus -&gt; matches.add(cus)))
      return matches;
  }
  </code></pre>
  
  <p>Is there a way to do this without the <code>matches</code> list? Can I perform some sort of reduction, so that the matching insurances are returned directly (i.e. not being added to a temporary collection like <code>matches</code>)?</p>