code: def _get_folder(gi, folder_name, library, libitems):
      
      for item in libitems:
          if item["type"] == "folder" and item["name"] == "/%s" % folder_name:
              return item
      return gi.libraries.create_folder(library.id, folder_name)[0]
docs: Retrieve or create a folder inside the library with the specified name.