Return the attribute that matches the reference. Raise an error if
        the attribute cannot be found, or if there is more then one match.

def get_attribute(self, reference):
        """
        Return the attribute that matches the reference. Raise an error if
        the attribute cannot be found, or if there is more then one match.
        """
        prefix, _, name = reference.rpartition('.')

        match = None
        for attribute in self._contents:
            if name == attribute.name and \
                    (not prefix or prefix == attribute.prefix):
                if match:
                    raise AttributeReferenceError(
                        'Ambiguous attribute reference: {}.'.format(
                            attribute.name))
                else:
                    match = attribute

        if match:
            return match
        raise AttributeReferenceError(
            'Attribute does not exist: {}'.format(reference))