public IEnumerable<WiniumElement> IterFind(TreeScope scope, Predicate<WiniumElement> predicate)
{
if (scope != TreeScope.Descendants && scope != TreeScope.Children)
{
throw new ArgumentException("scope should be one of TreeScope.Descendants or TreeScope.Children");
}
var walker = new TreeWalker(Condition.TrueCondition);
var elementNode = walker.GetFirstChild(this.AutomationElement);
while (elementNode != null)
{
var winiumElement = new WiniumElement(elementNode);
if (predicate == null || predicate(winiumElement))
{
yield return winiumElement;
}
if (scope == TreeScope.Descendants)
{
foreach (var descendant in winiumElement.IterFind(scope, predicate))
{
yield return descendant;
}
}
elementNode = walker.GetNextSibling(elementNode);
}
}