Refactoring getLastModified() from recursive to iterative.