<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_installed(package_name, service_name=None):
 """ Check whether the package package_name is currently installed. :param package_name: package name :type package_name: str :param service_name: service_name :type service_name: str :return: True if installed, False otherwise :rtype: bool """


    package_manager = _get_package_manager()

    app_installed = len(package_manager.installed_apps(package_name, service_name)) > 0

    subcommand_installed = False
    for subcmd in package.installed_subcommands():
        package_json = subcmd.package_json()
        if package_json['name'] == package_name:
            subcommand_installed = True

    return (app_installed or subcommand_installed)