classical
letf : CellPath d → (Fin d →ℤ) :=fun p i => pathIndex p i
havehf : Set.InjOn f T:=by
intro p hp q hq he
apply pathIndex_injective (((mem_dyadicPaths _ _).mp (hT hp)).trans
((mem_dyadicPaths _ _).mp (hT hq)).symm)
funext i
havehei : (pathIndex p i : ℤ) = pathIndex q i := congrFun he i
exact_mod_cast hei
have hh := ambientGridCenter_ball_card g (T.image f) x hr (fun a ha =>by
obtain ⟨p,hp,rfl⟩ :=Finset.mem_image.mp ha
havehe : p.length = g := (mem_dyadicPaths _ _).mp (hT hp)
simpa only [treeCenter,he] using hdist p hp)
rwa [Finset.card_image_of_injOn hf] at hh