def get_structure_index(structure_pattern,stream_index):
    """
    Translates the stream index into a sequence of structure indices identifying an item in a hierarchy whose structure is specified by the provided structure pattern.
    >>> get_structure_index('...',1)
    [1]
    >>> get_structure_index('.[.].',1)
    [1, 0]
    >>> get_structure_index('.[[...],..].',1)
    [1, 0, 0]
    >>> get_structure_index('.[[...]...].',2)
    [1, 0, 1]
    >>> get_structure_index('.[[...]...].',3)
    [1, 0, 2]
    >>> get_structure_index('.[[...]...].',4)
    [1, 1]
    >>> get_structure_index('.[[...]...].',5)
    [1, 2]
    >>> get_structure_index('.[[...]...].',6)
    [1, 3]
    >>> get_structure_index('.[[...]...].',7)
    [2]
    """
    structure_index = [0]
    current_stream_index = 0
    for p in structure_pattern:
        if p == '[':
            structure_index.append(0)
        elif p == '.':
            if current_stream_index == stream_index:
                return structure_index
            structure_index[-1] += 1
            current_stream_index += 1
        elif p == ']':
            structure_index.pop(-1)
            structure_index[-1] += 1
        else:
            raise Exception('Invalid character in structure pattern: %s' % repr(p))
    raise Exception('Provided stream index does not exist in the provided structure pattern')