use flattenIter from jsprim