Getting right eulers to tween to?

Entity1

Entity1 is rotated using setLocalEulers

Entity2
  Child Dummy2

I’m tweening Child Dummy2 and I need to get the right Y axis as Entity1 Y axis, without interacting with Entity2

The problem is that Entity1.getLocalEulerAngles() Y acts from (0,-90) and (0,90) while X, Z also changes.

I can only use this for a half side of the world and then it flips over, how can I achieve this conversion to (0,-180)(0,180)? Thanks

With the help of the X axis, it is possible to calculate when the axis overturns and we can calculate Y accordingly

        if (this.dummyEulers.x == 180 || this.dummyEulers.x == -180) {
             this.target.y = this.dummyEulers.y;
        }

         else if (this.dummyEulers.x == 0 || this.dummyEulers.x == -0) {
             diff = Math.abs(-90 - this.dummyEulers.y);
             this.target.y = -90 - (diff);
        }

It does the job, although this is not a very clean method