Remove redundant statements.
    
    The statement `a = 1` will be removed::
        
        a = 1
        a = 2

    The statement `a = 1` will not be removed because `b` depends on it::
        
        a = 1
        b = a + 2
        a = 2
        
    :param root: ast node

def remove_trivial(root):
    '''
    Remove redundant statements.
    
    The statement `a = 1` will be removed::
        
        a = 1
        a = 2

    The statement `a = 1` will not be removed because `b` depends on it::
        
        a = 1
        b = a + 2
        a = 2
        
    :param root: ast node
    '''

    gen = GatherAssignments()
    gen.visit(root)

    to_remove = []

    for symbol, assignments in gen.assign_id_map.items():
        if len(assignments) < 2:
            continue

        for j in range(len(assignments) - 1):
            i1 = root.body.index(assignments[j].root)
            i2 = root.body.index(assignments[j + 1].root)

            body = root.body[i1 + 1:i2]
            grapher = GraphGen()
            for stmnt in body:
                grapher.visit(stmnt)

            if symbol not in grapher.used:
                to_remove.extend(assignments[j].assignments)

    Pass = lambda node: _ast.Pass(lineno=node.lineno, col_offset=node.col_offset)

    for old in to_remove:
        replace_nodes(root, old, Pass(old))