Given a file path, removes all single-dot elements, as well as all double-dot elements and their preceding elements.