private static void DeepRemoveFilter(FilterElementCollection filterColl, FilterElement toRemoveFilter) { if (filterColl.Contains(toRemoveFilter)) { filterColl.Remove(toRemoveFilter); } foreach (FilterElement filterEl in filterColl) { if (filterEl.HasChildElements) { DeepRemoveFilter(filterEl.ChildElements, toRemoveFilter); } } }