flattenFiles = (hierarchy) => {
  let result = []
  hierarchy.forEach((fileOrFolder) => {
    if (fileOrFolder.children) {
      result = result.concat(flattenFiles(fileOrFolder.children))
    } else {
      result.push(fileOrFolder)
    }
  })
  return result
}
Create a flattened list of files from the given file heiarchy.
@return {Array} a list of file entries