Just to refresh, at the end of OoT, Link weakens Ganondorf and the sages seal him away in the Sacred Realm. Next, we see Zelda use the ocarina to send Link back in time. Later, we see Link as a child go up to Zelda in the castle courtyard.
Here's my idea: Link knew all that would happen, right? Now, we know that with the time travel used frequently throughout OoT by using the Master Sword, but obviously Zelda's ocarina-time-travel would be different, otherwise she wouldn't have felt the need to do it a different way. My idea is that this time it was Link's actual body in addition to his spirit that Zelda sent back, changed into the form of a child. Suppose she sends Link to the point directly after they met, as suggested by the fact that Zelda is still in the courtyard. He tells her that Ganon will soon escape the Sacred Realm with the ToP, and he tells her to go into hiding and to prepare for when the original Link is awakened in seven years. Meanwhile, the original Link is off in Dodongo's cavern or something, so he won't interfere with this. His work done, Link goes off to find a beloved friend and ends up in Termina. The original Link comes back after collecting the 3 sacred stones and sees Zelda running away from the castle. He falls asleep, and then in seven years he wakes up, seals Ganon, and gets sent back in Time by Zelda, tells her of what is to come, and goes to Termina. The result: an time loop for Link. However, this allows for both endings of Ocarina of Time to co-exist. Here it is written out:
(Events above and below each other happen simultaneously)