moving toArray(iterator) to sdk/util/array