public Item InsertWithoutDuplicating(Item item) {
Item existingItem = null;
if (!_seenItems.TryGetValue(item, out existingItem)) {
this.AddUnsafe(item);
return item;
}
// TODO: we're adding duplicate predecessors and reductions because we're rerunning the same completions twice when we have magic predictions
//if (existingItem.AddedFrom != "Completion" && existingItem.AddedFrom != "PredictionMagic") {
// throw new Exception();
//}
//if (item.AddedFrom != "Completion" && item.AddedFrom != "PredictionMagic") {
// throw new Exception();
//}
existingItem.Predecessors.UnionWith(item.Predecessors);
existingItem.Reductions.UnionWith(item.Reductions);
return existingItem;
}