def resolve_relative_to(self, view, template):
        if not isinstance(template, (collections.Mapping, MappingTemplate)):
            # disallow config.get(Filename(relative_to='foo'))
            raise ConfigTemplateError(
                u'relative_to may only be used when getting multiple values.'
            )

        elif self.relative_to == view.key:
            raise ConfigTemplateError(
                u'{0} is relative to itself'.format(view.name)
            )

        elif self.relative_to not in view.parent.keys():
            # self.relative_to is not in the config
            self.fail(
                (
                    u'needs sibling value "{0}" to expand relative path'
                ).format(self.relative_to),
                view
            )

        old_template = {}
        old_template.update(template.subtemplates)

        # save time by skipping MappingTemplate's init loop
        next_template = MappingTemplate({})
        next_relative = self.relative_to

        # gather all the needed templates and nothing else
        while next_relative is not None:
            try:
                # pop to avoid infinite loop because of recursive
                # relative paths
                rel_to_template = old_template.pop(next_relative)
            except __HOLE__:
                if next_relative in template.subtemplates:
                    # we encountered this config key previously
                    raise ConfigTemplateError((
                        u'{0} and {1} are recursively relative'
                    ).format(view.name, self.relative_to))
                else:
                    raise ConfigTemplateError((
                        u'missing template for {0}, needed to expand {1}\'s' +
                        u'relative path'
                    ).format(self.relative_to, view.name))

            next_template.subtemplates[next_relative] = rel_to_template
            next_relative = rel_to_template.relative_to

        return view.parent.get(next_template)[self.relative_to]
dataset/ETHPy150Open beetbox/beets/beets/util/confit.py/Filename.resolve_relative_to