<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def _parse_domain_caps(caps):
    '''
    Parse the XML document of domain capabilities into a structure.
    Return the domain capabilities given an emulator, architecture, machine or virtualization type.

    .. versionadded:: 2019.2.0

    :param emulator: return the capabilities for the given emulator binary
    :param arch: return the capabilities for the given CPU architecture
    :param machine: return the capabilities for the given emulated machine type
    :param domain: return the capabilities for the given virtualization type.
    :param connection: libvirt connection URI, overriding defaults
    :param username: username to connect with, overriding defaults
    :param password: password to connect with, overriding defaults

    The list of the possible emulator, arch, machine and domain can be found in
    the host capabilities output.

    If none of the parameters is provided the libvirt default domain capabilities
    will be returned.

    CLI Example:

    .. code-block:: bash

        salt '*' virt.domain_capabilities arch='x86_64' domain='kvm'
    '''
    result = {
        'emulator': caps.find('path').text if caps.find('path') is not None else None,
        'domain': caps.find('domain').text if caps.find('domain') is not None else None,
        'machine': caps.find('machine').text if caps.find('machine') is not None else None,
        'arch': caps.find('arch').text if caps.find('arch') is not None else None
    }

    for child in caps:
        if child.tag == 'vcpu' and child.get('max'):
            result['max_vcpus'] = int(child.get('max'))

        elif child.tag == 'iothreads':
            result['iothreads'] = child.get('supported') == 'yes'

        elif child.tag == 'os':
            result['os'] = {}
            loader_node = child.find('loader')
            if loader_node is not None and loader_node.get('supported') == 'yes':
                loader = _parse_caps_loader(loader_node)
                result['os']['loader'] = loader

        elif child.tag == 'cpu':
            cpu = _parse_caps_cpu(child)
            if cpu:
                result['cpu'] = cpu

        elif child.tag == 'devices':
            devices = _parse_caps_devices_features(child)
            if devices:
                result['devices'] = devices

        elif child.tag == 'features':
            features = _parse_caps_devices_features(child)
            if features:
                result['features'] = features

    return result