[backend] make loop detection work in _history link expansion