を行ったり来たりしていた

was going back and forth

→ を
phrase Rare #36,456
was going back and forth The を marks the area or route someone was moving along; the phrase describes repeated movement in both directions.
JA: 彼は駅の前を行ったり来たりしていた。
EN: He was going back and forth in front of the station.

見知らぬ男が私の家の前を行ったり来たりしていた。

A strange man was pacing back and forth in front of my house.

見知らぬ男が歩道を行ったり来たりしていた。

A strange man was pacing back and forth along the sidewalk.

いろんな考えが頭のなかを行ったり来たりしていた。

All kinds of thoughts were swirling around in my head.

トムは落ち着かない様子で部屋の中を行ったり来たりしていた。

Tom paced back and forth around the room restlessly.

彼は彼女の家の前を行ったり来たりしていた。

He was pacing back and forth in front of her house.