def _merge_config(new, base):
    """
        Internal function that merges config sections into a base config.

        Returns the new config data structure.
    """

    # Thanks, StackOverflow! http://stackoverflow.com/questions/823196/yaml-merge-in-python

    # If we've got two dicts, merge them.
    if isinstance(new, dict) and isinstance(base, dict):
        for k, v in base.items():
            if k not in new:
                new[k] = v
            else:
                new[k] = _merge_config(new[k], v)

    # If we didn't merge our dicts, this still returns the item we want to add.
    return new