here you have a сompound interrogative sentence, whos parts are connected by the conjunction до того, как
it's a fixed expression and its pronoun тот has fixed declination in Genitive as того due to presence of preposition до as you rightfully noted
so you simply have to remember this conjunction, its structure isn't unique in Russian, in compound sentences all conjunctions are formed by this or similar pattern through the use of как and что (чтобы)
потому, что/как
благодаря тому, что
после того, как
тогда, как
для того, чтобы
so summarizing, что (чтобы) is used in conjunctions of causative-consecutive relationship between the main and the secondary sentences, while как is used in conjunctions of tensed relationship between them
i hope i don't overgeneralize here and distinction by this principle is pretty accurate and consistent