title: Take all items except the last ones that satisfy condition?
body: <p>My specific requirement is that I have an <code>IEnumerable&lt;IEnumerable&lt;string&gt;&gt;</code>, and I want to "take" all items in the outer enumeration except any "empty" trailing items, where "empty" means all strings are null/empty or the inner enumeration is empty. Note that I want to keep any empty items that appear before the last non-empty one. For example:</p>
  
  <pre><code>Item 1: a, b, c
  Item 2: (nothing)
  Item 3: a, f, g, h
  Item 4: (nothing)
  Item 5: (nothing)
  </code></pre>
  
  <p>I would like to keep items 1–3 but trim items 4 and 5.</p>
  
  <p>In a more general sense, I have an enumeration of items, where I want to trim any trailing items that satisfy a condition, that appear behind the last item that does not satisfy the condition.</p>
  
  <p>For the sake of choosing an appropriate solution, I might add that the outer enumeration will usually contain a few hundred up to a few hundred thousand items, while the inner enumerations contain only a few items each. There will probably be only a couple of empty items that I need to trim.</p>
  
  <p>My current solution puts all outer items in a list (after transforming them with <code>.Select(...)</code>), and then in a loop keep removing the last item if it's empty, until a non-empty item is found.</p>