واسه خودش پیِ دوستِ همزبونی میگشت
He was looking for a sympathetic friend for himself.
The first word that you have questioned (پی) is a preposition for the verb (گشتن). It also might be translated "rear" or "back". sometime, this preposition is replaced by (دنبال) synonymously.
دنبال چیزی گشتن= پی چیزی گشتن = looking for something
نیم ساعت دنبال کتابم گشتم
دوست همزبون=دوست همزبان
همزبان = هم + زبان
"ham" is like "mate" in English:
classmate= class + mate
classmate = همکلاسی = هم + کلاس + ی
roommate = هم اتاقی = هم + اتاق + ی
"hamzabaan" means to have same language and also means a person who listen you wholeheartedly and understand you deeply.
hope this help.