public ImmutableArray <string> GetUnfinishedLeafTasks() { IList <Allocation> allUnfinished = GetUnfinishedAllocations(); ISet <Allocation> unfinishedLeaves = new LinkedHashSet <Allocation>(allUnfinished); // preserves order foreach (Allocation allocation in allUnfinished) { Maybe <Allocation> parent = allocation.GetParent(); while (parent.IsPresent()) { unfinishedLeaves.Remove(parent.Get()); parent = parent.Get().GetParent(); } } return(ImmutableArray.CreateRange( unfinishedLeaves.Select(a => a.GetDescription()).ToList())); }