internal void AddToDisposeList(AutomationElement elem) {
     disposeList.Add(elem);
 }
 public AutomationElement FindMatchingChild(Predicate<AutomationElement> pred) {
     IUIAutomationTreeWalker walker = factory.CreateTreeWalker();
     try {
         IUIAutomationElement elem;
         walker.GetFirstChildElement(pElement, out elem);
         while(elem != null) {
             AutomationElement ae = new AutomationElement(elem, factory);
             if(pred(ae)) {
                 return ae;
             }
             IUIAutomationElement next;
             walker.GetNextSiblingElement(elem, out next);
             elem = next;
         }
         return null;
     }
     catch(COMException) {
         return null;
     }
     finally {
         if(walker != null) Marshal.ReleaseComObject(walker);
     }
 }