def _normalise_path_segments(segments, absolute):
    """
    Normalises the supplied path segments.

    Collapses redundant pathing operators to produce a minimal set of path segments.

    This method expects a valid set of path segments (as exported by decompose()).

    :param segments: Path segments.
    :param absolute: True if the path is absolute, False if path is relative.
    :return: Normalised path segments.
    """
    new_segments = []
    for segment in segments:
        if segment == '.':
            continue
        if segment == '..':
            if absolute:
                if new_segments:
                    new_segments.pop()
            elif not new_segments or new_segments[-1] == '..':
                new_segments.append('..')
            else:
                new_segments.pop()
        else:
            new_segments.append(segment)
    return new_segments
