Fix pack.py:_walk_ref_chains

* reported https://github.com/jelmer/dulwich/issues/135