def resolve(self, key, entity):
        '''
        Resolve a key to an Entity. The optional `entity` argument is the
        "source" entity when resolving relationship targets.
        '''
        full_path = key

        if '.' not in key or key.startswith('.'):
            # relative target

            # any leading dot is stripped and with each dot removed,
            # the entity_module is stripped of one more chunk (starting with
            # the last one).
            num_dots = _leading_dots.match(full_path).end(1)
            full_path = full_path[num_dots:]
            chunks = entity.__module__.split('.')
            chunkstokeep = len(chunks) - num_dots
            if 0 < chunkstokeep:
                raise Exception("Couldn't resolve relative target "
                    "'%s' relative to '%s'" % (key, entity.__module__))
            entity_module = '.'.join(chunks[:chunkstokeep])

            if entity_module and entity_module is not '__main__':
                full_path = '%s.%s' % (entity_module, full_path)

            root = ''
        else:
            root = None
        return self.resolve_absolute(key, full_path, entity, root=root)
dataset/ETHPy150Open jmg/elixir/elixir/collection.py/RelativeEntityCollection.resolve/swapped operands of `<`