def _get_method(cls, key):
    """Get method for the given key.

    Args:
      key: Method ID, method name or (interface ID, method ID). If just method
        ID or name, the interface ID is looked up. Otherwise, the interface ID
        is used to get the correct method.
    Returns: Interface ID, Method object.
    """
    if isinstance(key, tuple):
        id, method_id = key
        if cls.id == id:
            key = method_id
        else:
            for supercls in cls.__superclasses__:
                if supercls.id == id:
                    return supercls._get_method(method_id)
    id = cls.id
    if isinstance(key, int):
        method = cls.__id_methods__.get(key)
    else:
        method = cls.__methods__.get(key)
    if not method:
        for supercls in cls.__superclasses__:
            id, method = supercls._get_method(key)
            if method is not None:
                break
    return id, method
