Fix #1544 (SO in dependencies extraction with macros and name hashing)

This PR addresses these bugs :
 * #1237 
 * #1408 
 * #1544 

The fix that was applied to `compile/interface/src/main/scala/xsbt/Dependency.scala` was unfortunately not sufficient, and sbt could still recurse infinitely over some nodes that had a cyclic chain of original-expanded trees.

To fix this problem, I ported the fix that was applied to `compile/interface/src/main/scala/xsbt/ExtractUsedNames.scala`, which required me to slightly change how dependencies are extracted, so that we can perform a more aggressive filter on nodes that we have already inspected.