def aliased(cls):
    """Class decorator used in combination with @alias method decorator."""
    orig_methods = cls.__dict__.copy()
    seen_aliases = set()
    for name, method in orig_methods.items():
        if hasattr(method, '_aliases'):
            collisions = method._aliases.intersection(orig_methods.keys() |
                seen_aliases)
            if collisions:
                raise ValueError(
                    'aliases collide with existing attributes: %s' % ({', '
                    .join(collisions)},))
            seen_aliases |= method._aliases
            for alias in method._aliases:
                setattr(cls, alias, method)
    return cls
