'Search an open port with a particular service.'

@staticmethod
def searchservice(srv, port=None, protocol=None):

    flt = {'service_name': srv}
    if (port is not None):
        flt['port'] = port
    if (protocol is not None):
        flt['protocol'] = protocol
    if (len(flt) == 1):
        return {'ports.service_name': srv}
    return {'ports': {'$elemMatch': flt}}
