Clean up the descendant iteration code.

Have a DescendantIter type for convenience.
Make the parameter of position type to make it clearer.