The expression “Barking up the wrong tree” comes from hunting raccoons.
Hunters use dogs to track down the little masked bandits, who will run into underbrush and, if cornered, climb a tree.
When the dogs find that tree, they park under it barking and baying until the brave human arrives with the gun.
By then, they will often find that the raccoon has outsmarted the dogs by crossing the branches to another tree and freedom.