I\'ve got a tree-like structure. Each element in this structure should be able to return a Enumerable of all elements it is root to. Let\'s call this method IEnumerabl
A better solution might be to create a visit method that recursively traverses the tree, and use that to collect items up.
Something like this (assuming a binary tree):
public class Node
{
public void Visit(Action action)
{
action(this);
left.Visit(action);
right.Visit(action);
}
public IEnumerable GetAll ()
{
var result = new List();
Visit( n => result.Add(n));
return result;
}
}
Taking this approach