Optimize out unnessary shared_nodes