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.
In the scripted test `source-dependencies/macro`, we get the following macro expansion : `0` (let's call it `exp`). Seeing that this is a macro expansion, we get that its original tree `orig` is `Provider.tree(0)`.

Now, we can `filter` from `orig` all trees that equal to `exp`. We get the following trees :
 * `Provider.tree(0)` (no original tree attached, not considered a macro expansion)
 * `Provider.tree` (no original tree attached, not considered a macro expansion)
 * `Provider` (no original tree attached, not considered a macro expansion)
 * ~~`0` (considered a macro expansion from `Provider.tree(0)`)~~ __filtered out__

If we use `traverseTrees` on this list, not only will we traverse multiple times some nodes, but we will also end up traversing again `0` (because it appears in `Provider.tree(0)`, which will be seen as a macro expansion and make us recurse infinitely.

Am I missing something ?