def _prepare_imports(self, dicts):
        pseudo_ids = set()
        pseudo_matches = {}
        prepared = dict(super(OrganizationImporter, self)._prepare_imports(dicts))
        for _, data in prepared.items():
            parent_id = data.get('parent_id', None) or ''
            if parent_id.startswith('~'):
                pseudo_ids.add(parent_id)
        pseudo_ids = [(ppid, get_pseudo_id(ppid)) for ppid in pseudo_ids]
        for json_id, data in prepared.items():
            for ppid, spec in pseudo_ids:
                match = True
                for k, v in spec.items():
                    if data[k] != v:
                        match = False
                        break
                if match:
                    if ppid in pseudo_matches:
                        raise UnresolvedIdError('multiple matches for pseudo id: ' + ppid)
                    pseudo_matches[ppid] = json_id
        network = Network()
        in_network = set()
        import_order = []
        for json_id, data in prepared.items():
            parent_id = data.get('parent_id', None)
            if parent_id in pseudo_matches:
                parent_id = pseudo_matches[parent_id]
            network.add_node(json_id)
            if parent_id:
                network.add_edge(parent_id, json_id)
        for jid in network.sort():
            import_order.append((jid, prepared[jid]))
            in_network.add(jid)
        if in_network != set(prepared.keys()):
            raise PupaInternalError("import is missing nodes in network set")
        return import_order