Why does Joseph have a staff in nativity scenes? I noticed that many nativity scenes present Joseph with a staff (in many cases a shepherd's staff). What was the original basis for this portrayal?

This answer is less concerned with the origin of the staff but suggests that it was a symbol of authority, suitable for a descendant of David, and was used in early stories as part of a miraculous sign.

Also, was the use of a shepherd's staff an original (or very early) conception, perhaps again relating to David, or a later change, perhaps a confusion with the staffs of the shepherds in nativity scenes?
In the Luke account, Joseph and Mary had just walked about 60 miles from Nazareth to the Jerusalem suburbs (Bethlehem is about 5 miles away.)  The countryside is hilly, and there are some dangerous places too.

Personally, if I'm walking more than a mile or so, I'm going to take a stick. And, if I've got a pregnant girl I need to protect, I'm doubly sure I'm going to have a stick.  Theology aside, this would be a very practical thing to take on a long walk in a dangerous area.

As an artist, if I'm trying to remind people that Joseph was on a journey, this would b a very simple shorthand for conveying that imagery.