Avoid endless loop for small directories.