Is there a way to delete unneeded keyframes automatically?
Yes you can. 

In the Dope Sheet, select all channels by pressing A while hovering over the list of channels, then press O. All unnecessary keyframes will be erased.