To bark up the wrong tree means to make an error in trying to succeed in something or in judging somebody.
1. When the policeman did not find any proof that the arrested man was a drug dealer, he realized that he was barking up the wrong tree.
2. When days of digging in the ruins turned up nothing, the archaeologist realized his team was barking up the wrong tree.
3. The participants in the treasure hunt realised that they were barking up the wrong tree when the clue lead them to a dead-end road.