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.
Well, what I meant is that instead of dropping traverse one can just record (in a private, mutable set) already visited originals and not process them again. This is what we tend to do when dealing with cyclic data structures in sbt. See: https://github.com/sbt/sbt/blob/0.13/compile/api/src/main/scala/xsbt/api/HashAPI.scala#L52

The HashAPI is overly generic because it has multiple different ways to cycle. For us, a simple mutable set is enough.

I find the mutable set + simple guard a bit easier to reason about because you know that there won't be looping no matter how long cycle chains are. For example, I can't see why your patch would handle `Provider.tree(Provider.tree(0))` properly and not loop.