How to get parent's data when its own data is null? : <p>I've a list like this:</p>

<pre><code>+ID+--+ParentID+--+Name+--+Code
+1-----NULL--------A-------Aa
+2-----NULL--------B-------Bb
+3-----2-----------B1------NULL
+4-----2-----------B2------NULL
+5-----1-----------A2------NULL
</code></pre>

<p>I get 'Code' values to another list by a linq query.</p>

<pre><code>var newList = new List&lt;string&gt;();
list.ForEach(x=&gt;newList.Add(x.Code))
</code></pre>

<p>However, if the <strong>Code</strong> is null or empty, I want to get its parent's 'Code'. So, my new list should contains</p>

<pre><code>+Aa
+Bb
+Bb
+Bb
+Aa
</code></pre>

<p>How can I do this with linq?</p>
