- "Would" is morphologically past tense and acts as the past tense of "will", and is used (among other things) for the future-in-the-past
- In a type 2 conditional, the verb in the protasis (the "if" clause) is also past tense (even irrealis "were" was traditionally called "past subjunctive"), even though it doesn't refer to the past: it represents an unreal or remote condition rather than the past
- A type 2 conditional can be read as a backshifted (into the past) type 1 conditional, even though it refers to an unreal present/future, not to the past.
To take the last point, since I think that is the most directly relevant to your question, picture someone saying "If I go there tomorrow, I will enjoy myself as much as I can and until I get too tired to continue" - in the second conditional this becomes "If I went there tomorrow, I would enjoy myself as much as I could and until I got too tired to continue".
Imagine that a magic spell is cast and someone finds that he is five years old. Assuming his powers of thought and speech are still intact, he might exclaim: "I'm five years old again - I'll sleep in every Saturday while I still have the chance!".
Backshifted, this becomes: "I was five years old again - I would sleep in every Saturday while I still had the chance". Hence, "have" becomes "had", and in the conditional "If I were five years old again, I would sleep in every Saturday while I still had the chance", the past tense is used in the subordinate "while" clause.
Imagine that someone becomes rich and is thinking: "I'm rich - I'll buy things every week until I run out of money". A stupid thought, but just an example.
Backshifted (as in reported speech or a later account of the person's thoughts), it becomes "I was rich. I would buy things every week until I ran out of money".
Similarly then in a second conditional it is "If I were rich, I would buy things every week until I ran out of money" - with a past tense in the subordinate "until" clause.