I think it should use IdentityHashMap, because we don't want to treat the graph on object equality, but on object identity.