Convert a flat representation of information (consisting of a fact list and a dictionary
        mapping node ids to attributes into a dictionary representation information.

        Input Example (CybOx)::


          { '00': { 'condition': 'Equals', 'datatype': 'String'},
            '01:L00:00': { 'condition': 'Equals', 'datatype': 'hexBinary'},
            '01:L00:01': { 'datatype': 'String'},
            '01:L01:00': { 'condition': 'Equals', 'datatype': 'hexBinary'},
            '01:L01:01': { 'datatype': 'String'}
          }

        Output Example::

            {'File_Name': {'@condition': 'Equals', '@datatype': 'String', '_value': u'UNITED NATIONS COMPENSATION SCHEME...pdf'},
              'Hashes': {'Hash': [{'Simple_Hash_Value':
                                    {'@condition': 'Equals',
                                     '@datatype': 'hexBinary',
                                      '_value': u'576fea79dd23a352a14c3f8bf3dbc9eb732e1d54f804a29160894aec55df4bd5'},
                                   'Type': {'@datatype': 'String', '_value': 'SHA256'}},
                                  {'Simple_Hash_Value': {'@condition': 'Equals',
                                                         '@datatype': 'hexBinary',
                                                         '_value': u'491809c2092cecd633e43d465409a78c'},
                                   'Type': {'@datatype': 'String', '_value': 'MD5'}}]
                        }
            }

def from_flat_repr(self,fact_list,include_node_id=False,no_attributes=False,track_namespaces=True,namespace_mapping=None):
        """
        Convert a flat representation of information (consisting of a fact list and a dictionary
        mapping node ids to attributes into a dictionary representation information.

        Input Example (CybOx)::


          { '00': { 'condition': 'Equals', 'datatype': 'String'},
            '01:L00:00': { 'condition': 'Equals', 'datatype': 'hexBinary'},
            '01:L00:01': { 'datatype': 'String'},
            '01:L01:00': { 'condition': 'Equals', 'datatype': 'hexBinary'},
            '01:L01:01': { 'datatype': 'String'}
          }

        Output Example::

            {'File_Name': {'@condition': 'Equals', '@datatype': 'String', '_value': u'UNITED NATIONS COMPENSATION SCHEME...pdf'},
              'Hashes': {'Hash': [{'Simple_Hash_Value':
                                    {'@condition': 'Equals',
                                     '@datatype': 'hexBinary',
                                      '_value': u'576fea79dd23a352a14c3f8bf3dbc9eb732e1d54f804a29160894aec55df4bd5'},
                                   'Type': {'@datatype': 'String', '_value': 'SHA256'}},
                                  {'Simple_Hash_Value': {'@condition': 'Equals',
                                                         '@datatype': 'hexBinary',
                                                         '_value': u'491809c2092cecd633e43d465409a78c'},
                                   'Type': {'@datatype': 'String', '_value': 'MD5'}}]
                        }
            }



        """

        if not namespace_mapping:
            namespace_mapping = {}
        name_counter = {'counter':0}



        def make_ns_slug(name_counter,slug='n'):
            while "%s%s" % (slug,name_counter['counter']) in namespace_mapping.values():
                name_counter['counter']  = name_counter['counter']+1

            return "%s%s" % (slug,name_counter['counter'])


        if include_node_id or track_namespaces:
            no_attributes=False

        def node_id_unpack(n):
            """
            Given a node_id, unpack it into list-signifier
            (if existing) and position information
            """
            return (n[0],int(n[1:]))

        fact_list.sort(key=lambda x : x['node_id'])

        result = self
        for fact in fact_list:

            current_ns_slug = {-1:None}
            fact_path = fact['term'].split('/')
            del(fact['term'])
            if fact.get('attribute'):
                if fact_path == [""]:
                    fact_path = []
                fact_path.append('@%s' % fact['attribute'])

                del(fact['attribute'])
            node_path = fact['node_id'].split(':')
            del(fact['node_id'])


            if '@@namespace_map' in fact.keys():
                namespace_map = fact['@@namespace_map']
                del(fact['@@namespace_map'])
            else:
                namespace_map = None



            walker = result
            walker_parent=None
            #logger.debug(fact)

            for i in range(0,len(node_path)):
                namespace_slug=None
                if track_namespaces and namespace_map:
                    #print namespace_map.namespaces_thru.get(position=i).namespace.uri
                    try:
                        namespace = namespace_map.namespaces_thru.get(position=i).namespace.uri
                    except:
                        namespace = None
                    if namespace:
                        if not namespace in namespace_mapping:
                            namespace_slug = make_ns_slug(name_counter)

                            namespace_mapping[namespace] = namespace_slug
                        else:
                            namespace_slug= namespace_mapping[namespace]

                current_ns_slug[i] = namespace_slug
                #if not current_ns_slug:
                #    current_ns_slug = namespace_slug

                (node_kind,counter) = node_id_unpack(node_path[i])
                element = fact_path[i]
                node_id = ':'.join(node_path[0:i+1])

                if no_attributes and i == len(node_path)-1 and node_kind== 'A':
                    continue

                if not (element in walker.keys()):

                    if node_kind == 'L':
                        walker[element] = []
                        child_dict = DingoObjDict()
                        if include_node_id:
                            child_dict['@@node_id'] = node_id
                        if namespace_slug and current_ns_slug[i] != current_ns_slug[i-1]:
                            child_dict['@@ns'] = current_ns_slug[i]
                            #child_dict['@@ns'] = fact.get('namespace_map').
                        walker[element].append(child_dict)
                        walker_parent = walker
                        walker = walker[element][0]
                    elif node_kind == 'N':
                        child_dict = DingoObjDict()
                        if include_node_id:
                            child_dict['@@node_id'] = node_id
                        if namespace_slug and current_ns_slug[i] != current_ns_slug[i-1]:
                            child_dict['@@ns'] = current_ns_slug[i]

                        walker[element] = child_dict
                        walker_parent = walker
                        walker = walker[element]

                else:

                    if node_kind == 'L':

                        if len(walker[element]) == counter:
                            next_item = DingoObjDict()
                            if include_node_id:
                                next_item['@@node_id'] = node_id
                            walker[element].append(next_item)
                            walker_parent=walker
                            walker=walker[element][counter]# next_item
                        elif len(walker[element]) > counter:
                            walker_parent=walker
                            walker = walker[element][counter]
                        else:
                            # TODO: introduce error logging
                            logger.error("ERROR: Structural problem for %s, counter %s and node_id %s" % (element,counter,node_id))
                            pass

                    else:
                        walker_parent=walker
                        walker=walker[element]
            if node_kind == 'A':

                if no_attributes:
                    continue
                if len(fact['value_list']) == 1:
                    value = fact['value_list'][0]
                else:
                    value = fact['value_list']
                if include_node_id:
                    walker[element] = {'@@node_id' : node_id,
                                       '_value' : value}
                else:
                    walker[element] = value
            else:
                if len(fact['value_list']) == 1:
                    if fact['value_list'][0] != '':
                        if no_attributes:
                            walker_parent[element] = fact['value_list'][0]
                        else:
                            walker['_value'] = fact['value_list'][0]
                else:
                    if no_attributes:
                        walker_parent[element] = fact['value_list']
                    else:
                        walker['_value'] = fact['value_list']
                if include_node_id:
                    walker['@@node_id'] = node_id

                del(fact['value_list'])


                if not no_attributes:
                    for key in fact:
                        if fact[key]:
                            walker[key] = fact[key]

        if track_namespaces:
            return namespace_mapping