large size of their country and vast population.
This is a complicate question. Let me try to give a brief explanation.
In ancient China, an idea of common identity, which can be named as Huaxia or Middle Kingom, can be found among nobles, officials and scholars. Professor Wang Mingke in Taiwan suggested that people created such idea because of external threats and distribution of resources. Giving definition to make sure friends and foes make things go easier. In "Spring and Autumn annuals with Mr. Gongyang commentary", people can be seen as a part of Huaxia when they acknowledge the same culture, living ways, decorum and diplomatic rules. If you recognize it then you are a member of Middle Kingdom, if not, you will be considered as barbarians. In Eastern Zhou Dynasty, barbarians may be people who lived in Canton, Fujian, Sichuan and Hunan. But the expansion of colonisation of Chinese rapidly changed the border between Huaxia and barbarians. More and more members entered the world of Huaxia. What we have to bear in mind is such sense of identity have nothing to do with peasants. The content of Huaxia is very different to nationalism and current Chinese identity.
A sense of collective identity that similar to current form actually appeared in late 19th century. Politicians and intellectuals in 19th century used history as an evidence to support the construction of Chinese nationalism. There were 3 key factors affected the progress, importation of western idea, development of communication and publishing, Sino-Japanese war. The first two factors allowed idea of nationalism spread in every class in Chinese society. However, the real turning point was the Sino-Japanese war in 1894-1895. After defeated by Japan, a concept flooded in China, "country destroyed, its people annihilated". The war report and fear transmitted through media and publishing. The whole country sank into mutual fear and discontent. Mutual feeling then transformed into a sense of collective identity. Intellectuals tried to utilize the trauma as a pressure to force Qing government to reform. Under this circumstance, the narrative of Modern Chinese history turned into a history of humiliate. We lost to Britain, we lost to France and now we lost to Japan. If we don't change, we will be erased by those who civilized. Sino-Japanese war created two impacts to China. The first one is what I mentioned, the rise of Chinese nationality. The next one is Chinese started to seek methods that can change China radically. And this related to the entrance of communism in the 1920s.
So, about the second part of your question, did that sense of collective identity facilitate the transition of Chinese society into communism? The answer is yes. Since the Chinese identity had already established, Mao and CCP didn't need to think how to create common identity. We can take a look into an article which written by Mao Zedong in 1939, "China's Revolution and Chinese Communist Party".(中國革命和中國共產黨) Mao said China is one of the eldest country on the earth and possessed a glorious past. However, China fall prey to imperialism and became a half-colonised country. From 1840 to 1939, China failed to defend herself and reform. Why China failed to strengthen herself? It's because China lack a strong and advanced party to lead the revolution. The only way for China to strive in the coming centuries is adopting communism and ruled by CCP. In this case, we can see Mao inherited narrative in the past with a little adjustment. The main focus of Mao is providing an answer, which is communism, to China, Chinese and Chinese History. To CCP, a sense collective identity was a solved question.
Mao's idea then turned into propaganda and content of history textbook. With the power of Leninist party and totalitarian government, Mao Zedong succeeded to unify and influence every person in China, which was the first time in Chinese history. People wanted a rapid and all-around change. Political power of CCP penetrate every corner in China society. So that's why CCP acquired enough energy to complete such a transition.
I hope this explanation could be helpful.
sources:
王明珂: "華夏邊緣",允晨文化,1997年3月
陳蘇鎮: "春秋與漢道",中華書局,2011年9月
金觀濤、劉青峰: "觀念史研究",法律出版社,2009年12月
毛澤東: "毛澤東選集 第二卷",人民出版社,1991年6月