internal static bool IsSupportedByBooleanOperator(this QueryElement element)
 {
     return(element.Type == QueryElementType.AnyQueryClause ||
            element.Type == QueryElementType.BooleanQueryClause ||
            element.Type == QueryElementType.ComparisonQueryClause ||
            element.Type == QueryElementType.Group);
 }
 internal static QueryElement CleanGroups(this QueryElement element)
 {
     if (element is BooleanQueryClause clause)
     {
         clause.Item1 = clause.Item1.CleanGroups();
         clause.Item2 = clause.Item2.CleanGroups();
     }
     else if (element is QueryElementGroup group)
     {
         if (group.Children.Count == 1)
         {
             element = group.Children.First().CleanGroups();
         }
         else
         {
             throw new InvalidOperationException();
         }
     }
     return(element);
 }
 internal static QueryElement HandleBooleanElements(this QueryElement element, BooleanOperator booleanOperator)
 {
     return(new List <QueryElement> {
         element
     }.HandleBooleanElements(booleanOperator).First());
 }