Create ``obj[segment]`` if missing.

        The default value for a missing segment is based on the *next*
        segment, unless a ``default`` is explicitly passed.

        If the next segment is an int, the default will be a list with
        the indicated number of items. Otherwise the default will be
        a :class:`Settings` dict.

def _create_segment(self, obj, segment, next_segment):
        """Create ``obj[segment]`` if missing.

        The default value for a missing segment is based on the *next*
        segment, unless a ``default`` is explicitly passed.

        If the next segment is an int, the default will be a list with
        the indicated number of items. Otherwise the default will be
        a :class:`Settings` dict.

        """
        if isinstance(next_segment, int):
            value = [PLACEHOLDER] * (next_segment + 1)
        else:
            value = Settings()
        if isinstance(obj, Mapping):
            if segment not in obj:
                obj[segment] = value
        elif isinstance(obj, Sequence):
            old_len = len(obj)
            new_len = segment + 1
            if new_len > old_len:
                obj.extend([PLACEHOLDER] * (new_len - old_len))
            if obj[segment] is PLACEHOLDER:
                obj[segment] = value