def get_method(name, attrs, bases, exclude=None):
    """ Gets a method of a class by name.

    :param name: Name of method to get.
    :type name: str

    :param attrs: Dictionary of class attributes.
    :type attrs: dict

    :param bases: Bases for the class to use for lookup.
    :type bases: list

    :param exclude: Iterable of bases to exclude from search.
    :type exclude: list

    :return: The class method or None
    """

    if exclude is None:
        exclude = []

    # If the method is present return it directly.
    if name in attrs:
        return attrs[name]

    # Try to find the method one by one
    for b in bases:
        sub_method = get_method(name, b.__dict__, b.__bases__, exclude=exclude)

        if sub_method is not None:
            if b in exclude:
                return None
            else:
                return sub_method

    # else return None
    return None