fix missing loop check
We failed to detect cyclic dependencies, leading to lost thread
roots. In this Ruby version, I also screwed up the `seen' hash
check in a misguided effort to avoid an extra hash lookup.
The same algorithm was recently fixed in public-inbox:
https://public-inbox.org/meta/
20180425085249.14974-1-e@80x24.org/
Summarizing what happened with public-inbox: this algorithm can
still be thrown off when the References: order presented to us
is wrong, so sorting messages by age before feeding to
Msgthr#add can improve the results.
Regardless of ordering, messages should not become "lost" by the
algorithm.