work both ends against the middle
work both sides against the middle
play both ends against the middle
play both sides against the middle
beat one's head against a stone wall
a house divided against itself cannot stand
bang one's head against a brick wall