from typing import Union


def _get_address_from_instance_response(instance_response: dict) -> Union[str, None]:
    """
    Extracts the instance's IP address (public if possible, private if not) from the boto3 response dict
    :param instance_response: Boto3 response dict
    :return: IP address of the instance (public if possible, private if not)
    """
    if instance_response['Reservations']:
        instance = instance_response['Reservations'][0]['Instances'][0]
        return instance['PublicIpAddress'] if 'PublicIpAddress' in instance else instance['PrivateIpAddress']
    else:
        return None