private HashSet<int> GetParentsBelowStackBased(Foo searchFromThis)
{
Stack<Foo> stack = new Stack<Foo>();
stack.Push(searchFromThis);
HashSet<int> set = new HashSet<int>();
while (stack.Count > 0)
{
Foo foo = stack.Pop();
if (foo.hasChildren)
{
set.Add(foo.id);
foreach (Foo foo2 in foo.children)
{
stack.Push(foo2);
}
}
}
return set;
}