public IEnumerable <AutomationElement> Find(AutomationElement element, IList <AutomationElement> collection, CancellationToken cancellationToken)
        {
            var input = _element.Find(element, null, cancellationToken);

            if (_reversed)
            {
                input = input.Reverse();
            }

            var condition = _condition as ICondition ?? throw new System.Exception($"PredicateElement condition ({_condition.GetType().Name}) does not implement ICondition.");

            return(input.Where((e, index) => condition.Matches(e, index)));
        }
        public IEnumerable <AutomationElement> Find(AutomationElement element, IList <AutomationElement> collection, CancellationToken cancellationToken)
        {
            var input = _element.Find(element, null, cancellationToken);

            if (_reversed)
            {
                input = input.Reverse();
            }

            var condition = _condition as ICondition ?? throw new System.Exception($"PredicateElement condition ({_condition.GetType().Name}) does not implement ICondition.");

            return(input.Where((e, index) =>
            {
                var matches = condition.Matches(e, index);
                System.Diagnostics.Debug.WriteLine($"PredicateElement: {e.ToDiagString()} at {index}: match? {matches}");
                return matches;
            }));
        }