def _flatten_elements(elm_def):
    """ Combine element with its base elements. """
    while 'base' in elm_def:
        base_elm = elm_def['base']
        elm_def.pop('base')
        elm_def['paths'] = elm_def.get('paths', []) + base_elm.get('paths', [])
        elm_def['labels'] = elm_def.get('labels', []) + base_elm.get('labels',
            [])
        elm_def['shapes'] = elm_def.get('shapes', []) + base_elm.get('shapes',
            [])
        d = base_elm.get('anchors', {}).copy()
        d.update(elm_def.get('anchors', {}))
        elm_def['anchors'] = d
        for i in base_elm:
            if i not in ['paths', 'labels', 'shapes', 'anchors'
                ] and i not in elm_def:
                elm_def[i] = base_elm[i]
    return elm_def
