@staticmethod
def prepare_platforms_and_targets(available, tid, available_target_ids):
    """
        prepare available platforms and target ids to flash
        """
    available_platforms = []
    target_ids_to_flash = []
    for device in available:
        available_target_ids.append(device['target_id'])
        if isinstance(tid, list):
            for item in tid:
                if device['target_id'] == item or device['target_id'
                    ].startswith(item):
                    if device['target_id'] not in target_ids_to_flash:
                        target_ids_to_flash.append(device['target_id'])
                    if 'platform_name' in device and device['platform_name'
                        ] not in available_platforms:
                        available_platforms.append(device['platform_name'])
        elif device['target_id'] == tid or device['target_id'].startswith(tid):
            if device['target_id'] not in target_ids_to_flash:
                target_ids_to_flash.append(device['target_id'])
            if 'platform_name' in device and device['platform_name'
                ] not in available_platforms:
                available_platforms.append(device['platform_name'])
    return available_platforms, target_ids_to_flash
