Making the method used to detect parent directory more consistant.