<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_parameter_dd(self, parameter):
 """ This method returns parameters as nested dicts in case of decision diagram parameter. """

        dag = defaultdict(list)
        dag_elem = parameter.find('DAG')
        node = dag_elem.find('Node')
        root = node.get('var')

        def get_param(node):
            edges = defaultdict(list)
            for edge in node.findall('Edge'):
                if edge.find('Terminal') is not None:
                    edges[edge.get('val')] = edge.find('Terminal').text
                elif edge.find('Node') is not None:
                    node_cpd = defaultdict(list)
                    node_cpd[edge.find('Node').get('var')] = \
                        get_param(edge.find('Node'))
                    edges[edge.get('val')] = node_cpd
                elif edge.find('SubDAG') is not None:
                    subdag_attribute = defaultdict(list)
                    subdag_attribute['type'] = edge.find('SubDAG').get('type')
                    if subdag_attribute['type'] == 'template':
                        subdag_attribute['idref'] = \
                            edge.find('SubDAG').get('idref')
                    if edge.find('SubDAG').get('var'):
                        subdag_attribute['var'] = \
                            edge.find('SubDAG').get('var')
                    if edge.find('SubDAG').get('val'):
                        subdag_attribute['val'] = \
                            edge.find('SubDAG').get('val')
                    edges[edge.get('val')] = subdag_attribute
            return edges

        if parameter.find('SubDAGTemplate') is not None:
            SubDAGTemplate = parameter.find('SubDAGTemplate')
            subdag_root = SubDAGTemplate.find('Node')
            subdag_node = subdag_root.get('var')
            subdag_dict = defaultdict(list)
            subdag_dict[subdag_node] = get_param(subdag_root)
            dag['SubDAGTemplate'] = subdag_dict
            dag['id'] = SubDAGTemplate.get('id')
        dag[root] = get_param(node)
        return dag