Factor out insertLocation() into Util.