what does I will not walk with bad men; that I may not be cast off with them. I will love the law, and keep it. I will walk with the just, and do good.
Basically in order or follow his beliefs he has to distance himself from the people that don’t align with his mindset. The apple doesn’t fall from the tree kind of thing.