Essentially rebuilding the latest version of a file is a matter of pushing diff references to a stack until you get to the original file then you pop the diff references off the stack and apply the diffs until the stack is empty.