cmdutils: make use of new iteration APIs