class AllocationCompletionTracker {

  ImmutableList<String> getUnfinishedLeafTasks() {
    List<Allocation> allUnfinished = getUnfinishedAllocations();
    Set<Allocation> unfinishedLeaves = new LinkedHashSet<>(allUnfinished); // preserves order

    for (Allocation allocation : allUnfinished) {
      Optional<Allocation> parent = allocation.getParent();

      while (parent.isPresent()) {
        unfinishedLeaves.remove(parent.get());
        parent = parent.get().getParent();
      }
    }

    return ImmutableList.copyOf(
        unfinishedLeaves.stream().map(Allocation::getDescription).collect(Collectors.toList()));
  }

}