Thread safety fix

Since NSMutableArray is not thread-safe, accumulate children stack using
regular single-threaded enumeration.