Done, via recursion.  But, instead of modifying the passed-in array, I copy per recurse, i.e. (pseudocode):

    def getStoragePath(paths):
      if paths === undefined: paths = STORAGE_PATHS_
      if paths.length === 0: throw Error
      if shell_is_writable(paths[0]): return paths[0]
      return getStoragePath(paths.slice(1))