private View createSectionHeaderIfNeeded(RecyclerView.Recycler recycler, int sectionIndex) {

        if (adapter.doesSectionHaveHeader(sectionIndex)) {

            // first, see if we've already got a header for this section
            for (int i = 0, n = getChildCount(); i < n; i++) {
                View view = getChildAt(i);
                if (getViewBaseType(view) == SectioningAdapter.TYPE_HEADER && getViewSectionIndex(view) == sectionIndex) {
                    return view;
                }
            }

            // looks like we need to create one
            int headerAdapterPosition = adapter.getAdapterPositionForSectionHeader(sectionIndex);
            View headerView = recycler.getViewForPosition(headerAdapterPosition);
            headerViews.add(headerView);
            addView(headerView);
            measureChildWithMargins(headerView, 0, 0);

            return headerView;
        } else {
            throw new IllegalStateException("createSectionHeaderIfNeeded should not be called for a section which does not have a header");
        }
    }
Get the header item for a given section, creating it if it's not already in the view hierarchy

@param recycler     the recycler
@param sectionIndex the index of the section for in question
@return the header, or null if the adapter specifies no header for the section
android/modules/module_common/src/main/java/github/tornaco/android/thanos/widget/section/StickyHeaderLayoutManager.java