def get_tasks_from_base_classes(bases, class_dict):
    """
    Function used by both TaskSetMeta and LocustMeta for collecting all declared tasks 
    on the TaskSet/Locust class and all it's base classes
    """
    new_tasks = []
    for base in bases:
        if hasattr(base, 'tasks') and base.tasks:
            new_tasks += base.tasks
    if 'tasks' in class_dict and class_dict['tasks'] is not None:
        tasks = class_dict['tasks']
        if isinstance(tasks, dict):
            tasks = tasks.items()
        for task in tasks:
            if isinstance(task, tuple):
                task, count = task
                for i in range(count):
                    new_tasks.append(task)
            else:
                new_tasks.append(task)
    for item in class_dict.values():
        if 'locust_task_weight' in dir(item):
            for i in range(0, item.locust_task_weight):
                new_tasks.append(item)
    return new_tasks
