Remove redundant path components from output