Replacing 4 Way Switch
3-way and 4-way circuits are simple. But they're made really strange because of the circumstances by which household wiring is done.  They're actually quite simple - forehead-slapping simple. 



How hard is that? Switches line up, light comes on. This one's off, by the way. 

Now a 4-way just goes in the middle between the 3-ways.  It either sends the yellows through straight, or crosses them.  Simple as that.   So what does that look like in actual wiring? 



Disregard the color of the passing-through wire. 

Notice the colored screws.   On 3-ways, there are 2 brass and the travelers go to them; black is common.   On 4-ways, there are 2 brass for one group of travelers, and 2 black for the other group. 

How do we tell which travelers are in the same group?  Easy!  They came out of the same cable or conduit!

Colors: the real devil here

Now I notice you're not using yellow for travelers. Actually, you're using red and white because houses are wired with this stuff:



Which only comes in the one set of colors - black red white.  And of course you entered this deal thinking wires were color-coded for purpose.  You were thinking the red/white meant something.  Nope. Installers are stuck with the colors that come in the cable. Sometimes it "works out"; but often - and always in 3-way circuits - color coding goes right out the window, and it's catch as catch can.  

They're only color-coded for purpose if you code them. That's why I own 10 colors of electrical tape :)  Mark wires religiously, both ends at the same time.  I'm fond of yellow for travelers since they are interchangeable (as you can see from the top drawing) and there's no need to distinguish one from another.