title: Nested filters using lambda
body: <p>I'm trying to code a multilevel filter. I have folders and files.</p>
  
  <pre><code>public class Folder {
    String name;
    List&lt;Folder&gt; folders;
    List&lt;File&gt; files;
    ...
  }
  
  public class File {
    String name;
    String type;
    ...
  }
  </code></pre>
  
  <p>I need a filter who looks for some property e.g. name, which can be a folder/file name. I wrote a piece of code that works for one level, but I don't how could I do that looking for two level loops. </p>
  
  <p>The final result would be a list of folders: the ones which names match the 'name filter' or folders which file names match the filter.</p>
  
  <pre><code>List&lt;Folder&gt; result = folders.stream()
    .filter(folder -&gt; folder.getFiles().stream().anyMatch(file -&gt; file.getName().contains(filter)))
    .collect(Collectors.toList());
  </code></pre>