This clever mechanism allows a segmental peg gear to reverse direction though the driving pinion continues to rotate in the same direction! I am guessing it was used as an elevator for a marble machine. The piece was recently featured on the Spiel und Kunst mit Mechanik blog.
The design of the mechanism is brilliant. A pinion gear drives a spoked peg gear located at a right angle to it. The peg gear features a compound mechanism. A section of the pegs have been removed and replaced with two horizontal wires (bent into curves). When the pinion reaches the end of the pegs, it disengages. At this moment, the end of the shaft upon which the pinion is mounted comes in contact with one of the two the horizontal wires on the peg gear. Because the entire drive shaft assembly is hinged (i.e. mounted on a single pivot located on the side farthest from the gear) it is free swing within a certain range from side to side. The turning drive shaft rides the horizontal wire, causing the entire drive assembly to shift to the opposite side of the peg gear, where it once again engages with the last pin of the peg gear. Because the pinion is now located on the other side of the peg gear, the gear will be driven in the opposite direction! The process is then reversed using the other horizontal wire. Truly ingenious.
[ Thanks Dave! ]