def compare_data(pre_data, post_data):
    """Compares two data stashes and returns the delta. If there is a new
    attr found on a node the delta dict will contain the following:
        {'node/path':
            {'NewAttr': [('attr_name', value)],
            'ChangedAttr': [],
            'NewNode': False}
    If an attr value changed the data will look like this:
        {'node/path':
                {'NewAttr': [],
                'ChangedAttr': [{'attr_name': (old_val, new_val)}],
                'NewNode': False}
    Lastly if the node is new the 'NewNode' key's value will be True
    :param pre_data:
    :param post_data:
    :return: Delta dict
    """
    changes = {}

    def get_changes_for_node(node_path):
        data_dict = changes.get(node_path, {'NewAttr': [], 'ChangedAttr': [],
                                            'NewNode': False})
        changes[node_path] = data_dict
        return data_dict
    # Loop pre-comp data looking for attr value changes
    for pre_path, pre_node_data in pre_data.items():
        # Check existing attrs for value changes
        try:
            new_pre_node_data = post_data[pre_path]
        except KeyError:
            new_pre_node_data = vars()
        if new_pre_node_data != pre_node_data:
            for attr, old_value in pre_node_data.items():
                try:
                    new_value = post_data[pre_path][attr]
                except KeyError:
                    new_value = object
                if new_value != old_value:
                    # Existing attr value changed
                    delta_dict = get_changes_for_node(pre_path)
                    delta_dict['ChangedAttr'] += [{attr: (old_value,
                                                          new_value)}]
    # Loop post-comp data looking for new attrs
    for post_path, post_node_data in post_data.items():
        # Check for attrs that are new
        if pre_data.get(post_path) is None:
            delta_dict = get_changes_for_node(post_path)
            delta_dict['NewNode'] = True
        for attr, new_value in post_node_data.items():
            try:
                _ = pre_data[post_path][attr]
                attr_not_found = False
            except KeyError:
                attr_not_found = True
            if attr_not_found:
                delta_dict = get_changes_for_node(post_path)
                delta_dict['NewAttr'] += [(attr, new_value)]
    return changes