right. we want to return undefined only if we are not at the last segment of the path.