<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _package_exists(path):
 # type: (str) -> bool """ Checks if the given Python path matches a valid file or a valid container file :param path: A Python path :return: True if the module or its container exists """

    while path:
        if os.path.exists(path):
            return True
        else:
            path = os.path.dirname(path)

    return False