<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def download(client, target_dir):
 """Download images from play store into folder herachy."""

    print('download image previews')
    print(
        "Warning! Downloaded images are only previews!"
        "They may be to small for upload.")
    tree = {}
    listings = client.list('listings')
    languages = map(lambda listing: listing['language'], listings)

    parameters = [{'imageType': image_type, 'language': language}
                  for image_type in image_types for language in languages]
    tree = {image_type: {language: list()
                         for language in languages}
            for image_type in image_types}

    for params in parameters:
        result = client.list('images', **params)
        image_type = params['imageType']
        language = params['language']
        tree[image_type][language] = map(
            lambda r: r['url'], result)

    for image_type, language_map in tree.items():
        for language, files in language_map.items():
            if len(files) > 0:
                mkdir_p(
                    os.path.join(target_dir, 'images', image_type, language))
            if image_type in single_image_types:
                if len(files) > 0:
                    image_url = files[0]
                    path = os.path.join(
                        target_dir,
                        'images',
                        image_type,
                        language,
                        image_type)
                    load_and_save_image(image_url, path)
            else:
                for idx, image_url in enumerate(files):
                    path = os.path.join(
                        target_dir,
                        'images',
                        image_type,
                        language,
                        image_type + '_' + str(idx))
                    load_and_save_image(image_url, path)