Why not just leave the '..' portions in the path? Though the result, after having removed them, might be more aesthetically pleasing, it's really up to the OS how to interpret the updir. To "do the right thing" you probably will end up needing to chdir followed by a cwd.
For a more thorough discussion of what you're up against, check out some of my comments in Absolute pathnames from relative?.
Matt