up() function to pattern match traverse up dir tree