title: Filtering a list of object based on nested type
body: <p>Lets say I have a class as follows:</p>
  
  <pre><code>case class Person(
  name:String,
  age:Int,
  dependents:List[Person]
  )
  </code></pre>
  
  <p>Lets say I have the following four people:</p>
  
  <pre><code>val p1 = Person("Tom",50,List(p2,p4))
  val p2 = Person("Bob",20,List(p3))
  val p3 = Person("Jimmy",25,List(p4))
  val p4 = Person("Harry",11,Nil)
  </code></pre>
  
  <p>My people list is val pList = List(p1,p2,p3,p4)</p>
  
  <p>I want to filter this collection to get all the people who have an 11 year old dependent.</p>
  
  <p>What is one way to do it?</p>
  
  <p>The algorithm can be summed up as For each dependent(d) of each person(p) in pList, if age of dependant(d) is == 11, collect the person(p).</p>
  
  <p>How do I express it in scala?</p>