@Override
    public boolean visitTree(VisitContext context, VisitCallback callback) {
        if (!isRepeating()) {
            // interpret unloaded tab as SKIP_UNRENDERED
            // otherwise we visit them now and they get "partly" loaded; see #9168
            if (context.getHints().contains(VisitHint.SKIP_UNRENDERED) && isDynamic()) {
                try {
                    pushComponentToEL(context.getFacesContext(), this);

                    VisitResult res = context.invokeVisitCallback(this, callback);

                    if (res == VisitResult.COMPLETE) {
                        return true;
                    }
                    else if (res == VisitResult.REJECT) {
                        return false;
                    }

                    for (int i = 0; i < getChildCount(); i++) {
                        UIComponent child = getChildren().get(i);
                        if (child instanceof Tab) {
                            Tab tab = (Tab) child;
                            if (tab.isLoaded()) {
                                if (tab.visitTree(context, callback)) {
                                    return true;
                                }
                            }
                        }
                    }
                }
                finally {
                    popComponentFromEL(context.getFacesContext());
                }

                return false;
            }
            else {
                return super.visitTree(context, callback);
            }
        }
        else {
            // override the behavior from UIComponent to visit
            // all children once per "row"

            if (ComponentUtils.isSkipIteration(context, context.getFacesContext())) {
                return super.visitTree(context, callback);
            }

            if (!isVisitable(context)) {
                return false;
            }

            // save the current index, count aside
            final int prevIndex = _index;
            final int prevCount = _count;

            // validate attributes
            validateAttributes();

            // reset index and save scope values
            captureScopeValues();
            setIndex(-1);

            // push the Component to EL
            pushComponentToEL(context.getFacesContext(), this);
            try {
                VisitResult res = context.invokeVisitCallback(this, callback);
                switch (res) {
                    // we are done, nothing has to be processed anymore
                    case COMPLETE:
                        return true;

                    case REJECT:
                        return false;

                    //accept
                    default:
                        // determine if we need to visit our children
                        // Note that we need to do this check because we are a NamingContainer
                        Collection<String> subtreeIdsToVisit = context
                                .getSubtreeIdsToVisit(this);
                        boolean doVisitChildren = subtreeIdsToVisit != null
                                && !subtreeIdsToVisit.isEmpty();
                        if (doVisitChildren) {
                            // visit the facets of the component
                            if (getFacetCount() > 0) {
                                for (UIComponent facet : getFacets().values()) {
                                    if (facet.visitTree(context, callback)) {
                                        return true;
                                    }
                                }
                            }

                            // visit the children once per "row"
                            if (getChildCount() > 0) {
                                int i = getOffset();
                                int end = getSize();
                                int step = getStep();
                                end = (end >= 0) ? i + end : Integer.MAX_VALUE - 1;
                                _count = 0;

                                setIndex(i);
                                while (i <= end && isIndexAvailable()) {
                                    for (int j = 0, childCount = getChildCount(); j < childCount; j++) {
                                        UIComponent child = getChildren().get(j);
                                        if (child.visitTree(context, callback)) {
                                            return true;
                                        }
                                    }

                                    _count++;
                                    i += step;

                                    setIndex(i);
                                }
                            }
                        }
                        return false;
                }
            }
            finally {
                // pop the component from EL
                popComponentFromEL(context.getFacesContext());

                // restore the previous count, index and scope values
                _count = prevCount;
                setIndex(prevIndex);
                restoreScopeValues();
            }
        }
    }
Calculates the count value for the given index.

@param index

@return
primefaces/src/main/java/org/primefaces/component/api/UITabPanel.java