に滞在していた

had been staying in

→ に
phrase Rare #39,907
had been staying in 滞在していた means “was staying” or “had been staying”; に marks the place where someone stayed.
JA: 私は去年、京都に滞在していた。
EN: I was staying in Kyoto last year.

彼女は少し前に滞在していた。

She had been staying there until a little while ago.

彼はかなり長い時間そこに滞在していた。

He stayed there for quite a long time.

彼女は少しの間そのあたりに滞在していた。

She stayed around there for a while.

私は日本に帰ってくる前にずっとボストンに滞在していた。

I had been staying in Boston before returning to Japan.