Sort directories for traversal
Skip empty directories
Curry shift into functions