public static IList<ITree> GetAncestors(ITree t)
{
if (t.Parent == null)
{
return Collections.EmptyList<ITree>();
}
IList<ITree> ancestors = new List<ITree>();
t = t.Parent;
while (t != null)
{
ancestors.Insert(0, t);
// insert at start
t = t.Parent;
}
return ancestors;
}