This one's more than a little tricky. But let's start by reviewing how 3-way circuits work in the first place.
(And by the way, you didn't make life any easier on yourself by unhooking all the wirenuts in the box. The right way to do this is only unhook the 2 wires that were hooked to the old light, aside from ground.)
So here's a basic 3-way circuit. Now I am a huge fan of identifying wires by color. I use wires in conduit, so I get to do that. With black-white-red cable, you can accomplish the same thing by marking both ends of the wire with colored electrical tape. I strongly recommend labeling as you figure out the circuit, and then always thereafter.
- Black - supply always-hot
- White - supply neutral
- Yellow pair - messengers (they are interchangeable, so you don't need to distinguish them from each other) Alt traveler color: blue.
- Red - switched-hot - hot when light is desired to be on.
Note that between the 3-ways, is "/3" cable (3-wire) cable. This is to accommodate a special rule: In any cable or conduit, currents must be equal. If one of the travelers is taking power to the lamp, the power must return via the neutral in the same cable etc. That's why I drew it very thin with wires bunched.
This isn't your circuit, though. Yours is a little more complicated because with 3 control points, it must involve a 4-way switch (UK:3-way). But not that more complicated: take a look.
You can see I've moved the bulb, but it's just cosmetic; it doesn't really affect the circuit any. And the 4-way just goes mid-line along the two travelers - inputs 2 travelers, outputs 2 travelers. You can have as many 4-ways as you please, just like that. I just left the second set of travelers yellow... it's not that complicated. Note the screw colors (brass/black).
Now. Imagine the first 3-way (and the passthrough neutral) is in a box. Imagine the bulb and 2 yellow messengers passing through) are in another box. Imagine the 4-way (and passing through switched-hot) are in another box. That is exactly how your house is wired.
In this drawing I changed the second set of travelers to blue, supply hot to brown, neutral to gray and switched-hot to orange. Never mind that, though.
Physically, it'd look like this if we color-taped all the wires (a lot). Note that in the /3 cable, the underlying hard colors used in your house could be absolutely anything.
Though I cannot say whether the bulb is left or right of the 4-way -- as you can see from the drawing, it changes very little either way.
So now you have some detective work to do. Take apart your switches, but don't remove any wires :) Among your switches:
- The 3-way switch with only one cable in the box is the remote (far-end) 3-way. The two wires on brass screws are the messengers, the other will surely be switched-hot.
- Only travelers will go to the 4-way switch. That'll be two wires from one cable, and two wires from the other cable. All those are travelers. The remaining wire from each cable is "passthrough" either neutral or switched hot.
- The other 3-way switch will have 2 cables (a /2 and a /3 cable) - the /2 cable will be power supply source. Again, the two wires on brass screws are the messengers and will go into the same cable. On the supply cable, black will be supply-hot and white will be supply-neutral.
- Up in the lamp, 2 wires from each cable will be travelers. The remaining wires will be switched-hot and neutral.
It's also remotely possible that the power supply enters the 4-way box. Let me know if that's the case, it makes the drawing slightly different, but not shatteringly so.