Rigging: yaw + pitch problem
I think you mean for the bottom element to yaw (turn left and right) but not to pitch (forward and back). Either way, you can lock any bone to the desired rotation by clicking on the appropriate padlock icon next to the x/y/z rotational axes for the bone at the top of the Properties panel.