Well, in the AnimationPlayer node you can add a method call at a particular frame. It works like a signal which calls a method. In that method you can have whether branching you like.
Also, have you considered using AnimationTree? That's a node that's there for precisely this sort of animation management.
There are several options, one is to use a BlendTree, so you can tie the animations together, you can blend them, you can add a TimeScale to forwards and backwards, a seek to jump to a particular point, etc. then you can add a script to this node and just call it.
Otherwise there's 2d and 3d blend spaces which will lerp between states. Or there's a state machine.
Much easier to use these nodes than code everything. It's very powerful.