public static bool RemoveCondition(this FilterExpression filter, ConditionExpression condition, ITracingService trace = null) { if (filter?.Conditions?.Contains(condition) == true) { trace?.Trace($"Removing condition: {condition.Stringify()}"); filter.Conditions.Remove(condition); return(true); } var result = false; foreach (var subfilter in filter.Filters) { if (subfilter.RemoveCondition(condition, trace)) { result = true; } } filter.Filters.RemoveEmptyFilters(trace); return(result); }