On a codimension $2$ bifurcation of heteroclinic orbits