buildTreeMap should not overwrite last item