Do not use the .NET UIAUTOMATION anymore!
It is obsolete and buggy.
Please read my detailed answer here:
c# - System.Windows.Automation is extremely slow - Stack Overflow
UIAutomation is very thread-critical!
1.) You MUST access an AutomationElement always only from one and the same thread.
2.) The thread must be STA thread (Single Threaded Apartment)
before starting the thread.
Otherwise you may get the effect that TreeWalker.GetFirstChild() or AutomationElement.FindAll() may return only a PART of the children of an AutomationElement (for example it may return 3 of 10 children)
This missing children bug is very difficult to reproduce (and may happen e.g. on a Table but not on a Pane)
I can reproduce this bug with a DataGrid control in a .NET application where only one row of 10 rows is returned.