public void InsertSameTreeIntoTree() { var tree = MergedIntervalTree.Create(ExistingIntervals); foreach (var target in ExistingIntervals) { tree.Add(target); } // non-overlapping should have one more interval MultiAssert.True(ExistingIntervals.SequenceEqual(tree)); // subtract back the stuff we added to get leftovers. var fpTree = MergedIntervalTree.Create <uint>(); foreach (var interval in tree) { var overlaps = ExistingTree.Search(interval).ToList(); if (overlaps.Count == 0) { fpTree.Add(interval); } else { fpTree.AddRange(interval.Subtract(overlaps)); } } // since we added the same, leftovers should be none. MultiAssert.False(fpTree.Any()); MultiAssert.AssertAll(); }