Switch to a loop; forgot Python couldn't do recursion.
Merge pull request #1170 from kennknowles/copy-doc-type-command

Switch to a loop; forgot Python couldn't do recursion.