It would require a sea change in thinking, or get people comfortable with the idea of not belonging to nations.
As you point out Nationalism has been a pretty recent development. It has mostly been enforced by indoctrination in the education systems and culture. While it has had many many issues, we have seen it reduce the number of conflicts and wars by a lot, and thus it appears to be a reasonable solution.
Whatever solution aims to replace it would have to not only overcome all of these barriers, but provide better results as well.