<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 listing files from play and saves them into folder herachy."""

    print('')
    print('download store listings')
    print('---------------------')
    listings = client.list('listings')
    for listing in listings:
        path = os.path.join(target_dir, 'listings', listing['language'])
        mkdir_p(path)
        with open(os.path.join(path, 'listing.json'), 'w') as outfile:
            print("save listing for {0}".format(listing['language']))
            json.dump(
                listing, outfile, sort_keys=True,
                indent=4, separators=(',', ': '))