 <p>Try this:</p> <pre><code>virtual public IEnumerable&lt;string&gt; GetSelectedIds(){ if (_kids == null){ yield return null; yield break; } foreach (var current in _kids.Nodes) yield return current; } </code></pre>