Remove unnecessary paths from path