Infinite loop caused by objects with no keys

checking objects both directions fixes this