<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def loadYAML (filename=None, data=None):
 """Loads either the given YAML configuration file or YAML data. Returns None if there was an error reading from the configuration file and logs an error message via ait.core.log.error(). """

    config = None

    try:
        if filename:
            data = open(filename, 'rt')

        config = yaml.load(data)

        if type(data) is file:
            data.close()
    except IOError, e:
        msg = 'Could not read AIT configuration file "%s": %s'
        log.error(msg, filename, str(e))

    return config