I was deep in thought while I was walking, and almost stepped on a dead bird.
この場合、次のような言い方ができますよ。
ーI was deep in thought while I was walking, and almost stepped on a dead bird.
「歩きながら考え込んでいたら、死んだ鳥を踏みそうになった」
to be deep in thought で「考え込む・物思いにふける」
ご参考まで!