let get_target t id =
let rec get_following_pointers ~key ~count =
get_stored_target t key
>>= fun stored ->
begin match Target.Stored_target.get_target stored with
| `Pointer _ when count >= 30 ->
fail (`Missing_data (fmt "there must be a loop or something (from %s)" id))
| `Pointer key ->
get_following_pointers ~count:(count + 1) ~key
| `Target t -> return t
end
in
get_following_pointers ~key:id ~count:0