private BookmarkNode loadBookmarkFolder(long folderId) {
      if (ThreadUtils.runningOnUiThread()) {
        Log.e(TAG, "Trying to load bookmark folder from the UI thread.");
        return null;
      }

      // If the current folder id doesn't exist (it was deleted) try the current parent.
      // If this fails too then fallback to Mobile Bookmarks.
      if (!ChromeBrowserProviderClient.bookmarkNodeExists(mContext, folderId)) {
        folderId =
            mCurrentFolder != null
                ? getFolderId(mCurrentFolder.parent())
                : ChromeBrowserProviderClient.INVALID_BOOKMARK_ID;
        if (!ChromeBrowserProviderClient.bookmarkNodeExists(mContext, folderId)) {
          folderId = ChromeBrowserProviderClient.INVALID_BOOKMARK_ID;
        }
      }

      // Need to verify this always because the package data might be cleared while the
      // widget is in the Mobile Bookmarks folder with sync enabled. In that case the
      // hierarchy up folder would still work (we can't update the widget) but the parent
      // folders should not be accessible because sync has been reset when clearing data.
      if (folderId != ChromeBrowserProviderClient.INVALID_BOOKMARK_ID
          && !AndroidSyncSettings.isSyncEnabled(mContext)
          && !ChromeBrowserProviderClient.isBookmarkInMobileBookmarksBranch(mContext, folderId)) {
        folderId = ChromeBrowserProviderClient.INVALID_BOOKMARK_ID;
      }

      // Use the Mobile Bookmarks folder by default.
      if (folderId < 0 || folderId == ChromeBrowserProviderClient.INVALID_BOOKMARK_ID) {
        folderId = ChromeBrowserProviderClient.getMobileBookmarksFolderId(mContext);
        if (folderId == ChromeBrowserProviderClient.INVALID_BOOKMARK_ID) return null;
      }

      return ChromeBrowserProviderClient.getBookmarkNode(
          mContext,
          folderId,
          ChromeBrowserProviderClient.GET_PARENT
              | ChromeBrowserProviderClient.GET_CHILDREN
              | ChromeBrowserProviderClient.GET_FAVICONS
              | ChromeBrowserProviderClient.GET_THUMBNAILS);
    }
      @Override
      protected Void doInBackground(Void... params) {
        // If we're in the Mobile Bookmarks folder the icon to go up the hierarchy
        // will either appear or disappear. Need to refresh.
        long mobileBookmarksFolderId =
            ChromeBrowserProviderClient.getMobileBookmarksFolderId(mContext);
        if (mCurrentFolderId == mobileBookmarksFolderId) {
          refreshWidget();
          return null;
        }

        // If disabling sync, we need to move to the Mobile Bookmarks folder if we're
        // not inside that branch of the bookmark hierarchy (will become not accessible).
        if (!mEnabled
            && !ChromeBrowserProviderClient.isBookmarkInMobileBookmarksBranch(
                mContext, mCurrentFolderId)) {
          requestFolderChange(mobileBookmarksFolderId);
        }

        return null;
      }