code: public void toggle(final int position) {
          long itemId = getItemId(position);
          boolean isExpanded = mExpandedIds.contains(itemId);
  
          View contentParent = getContentParent(position);
          if (contentParent != null) {
              toggle(contentParent);
          }
  
          if (contentParent == null && isExpanded) {
              mExpandedIds.remove(itemId);
          } else if (contentParent == null) {
              mExpandedIds.add(itemId);
          }
      }
docs: Toggle the {@link android.view.View} at given position, ignores header or footer Views.
  
  @param position the position of the view to toggle.