'Returns the default attribute set in a parent tag like <handlers> or
<destinations>, or return the ID of the child, if there is no explicit
default and only one child.
:param parent: Object representing a tag that may or may not have a \'default\' attribute.
:type parent: ``xml.etree.ElementTree.Element``
:param names: The list of destination or handler IDs or tags that were loaded.
:type names: list of str
:returns: str -- id or tag representing the default.'

def _get_default(self, config, parent, names):

    rval = parent.get('default')
    if ('default_from_environ' in parent.attrib):
        environ_var = parent.attrib['default_from_environ']
        rval = os.environ.get(environ_var, rval)
    elif ('default_from_config' in parent.attrib):
        config_val = parent.attrib['default_from_config']
        rval = config.config_dict.get(config_val, rval)
    if (rval is not None):
        if (rval not in names):
            raise Exception(("<%s>    default    attribute    '%s'    does    not    match    a    defined    id    or    tag    in    a    child    element" % (parent.tag, rval)))
        log.debug(("<%s>    default    set    to    child    with    id    or    tag    '%s'" % (parent.tag, rval)))
    elif (len(names) == 1):
        log.info(("Setting    <%s>    default    to    child    with    id    '%s'" % (parent.tag, names[0])))
        rval = names[0]
    else:
        raise Exception(("No    <%s>    default    specified,    please    specify    a    valid    id    or    tag    with    the    'default'    attribute" % parent.tag))
    return rval
