This parallels one of the writings of Chuang Tzu, a Taoist sage:
“Once Chuang Chou dreamt he was a butterfly, a butterfly flitting and fluttering around, happy with himself and doing as he pleased. He didn’t know he was Chuang Chou. Suddenly he woke up, and there he was, solid and unmistakable Chuang Chou. But he didn’t know if he was Chuang Chou who had dreamt he was a butterfly, or a butterfly dreaming he was Chuang Chou.”