def _normalizepath(path_segments):
    """
	Internal helper function for normalizing a path list.

	Should be equivalent to RFC2396, Section 5.2 (6) (c)-(f) with the exception
	of removing empty path_segments.
	"""
    new_path_segments = []
    l = len(path_segments)
    for i in range(l):
        segment = path_segments[i]
        if not segment or segment == '.':
            if i == l - 1:
                new_path_segments.append('')
        elif segment == '..' and len(new_path_segments) and new_path_segments[
            -1] != '..':
            new_path_segments.pop()
            if i == l - 1:
                new_path_segments.append('')
        else:
            new_path_segments.append(segment)
    return new_path_segments
