Joseph, son of Jacob, was a dreamer.
Joseph, father of Jesus, was visited by an angel of the Lord through dreams, as well. And what was his father’s name? Jacob (Mat 1.16).
And, yes, both of them went to Egypt.
The first Joseph brought the whole family of Jacob to Egypt, who was threatened of extinction by famine. Another threat brought the little family of Joseph, Mary, and Jesus to Egypt. The threat was not famine, though, this time around, but the threat of Herod.
Nevertheless, the journey to Egypt signalled the birth of a new nation, the nation of Israel. Around four hundred years later, Moses would lead these descendants of Jacob for an Exodus out of Egypt. Similarly, the journey to Egypt for the family of Joseph, Mary, and Jesus occurred just after the birth of Jesus; the Messiah, the representative of Israel, the true Israel. And, similarly, later Jesus would bring a new Exodus for Israel out of Egypt — the Egypt of death.
“Out of Egypt I called my son,” thus said the word of the Lord, as recorded by the prophet Hosea. And yet the more they were called, the more they went away; original Israel kept sacrificing to the Baals and burning offerings to idols (Hos 11.1-2). But not this time around with Jesus. The true Son would obey his calling. He would not go away.