Wiktionary
know which side one's bread is buttered on
vb. (context idiomatic English) To be aware of where one's interests lie in a situation.