Green’s Dictionary of Slang

bark up the wrong tree v.

also bark up the wrong creek, be up the wrong tree, jump the wrong stump
[the image of a dog chasing a raccoon into a tree]

[early 19C+] (orig. US) to make a mistake, to misdirect one’s efforts.