Its also an animal trap involving rope and bent branches.
I believe the original saying goes back to Shakespeare and I believe the term "petard" got applied to that type of animal trap only in the 19th century. But that's a quibble.