read_directory_recursive(): refactor handling of a single path into a separate function