testAllInternal_ converted from recursion to iteration, is it won't overflow the stack with large objects.