early node deduplication. speeds up shepherd compilation by about 10x in medium

Hello @giannic, @majelbstoat, @dpup, 

Please review the following commits I made in branch 'nick-optimize'.

3b74e8ee6b7dd9d55df6b0136233a88bec1a0b51 (2014-05-15 18:25:05 -0400)
early node deduplication. speeds up shepherd compilation by about 10x in medium

R=@giannic
R=@majelbstoat
R=@dpup