(include_only_ids, loc_type_db)
return include_only
The user specified that we include loc types `include_only_ids`, but
        we need to insert any parent location types
The user specified that we include loc types `include_only_ids`, but
        we need to insert any parent location types
The user specified that we include loc types include_only_ids but we need to insert any parent location types
def _get_include_only(include_only_ids, loc_type_db):
        """The user specified that we include loc types `include_only_ids`, but
        we need to insert any parent location types"""
        loc_types_by_pk = {lt.pk: lt for lt in loc_type_db.values()}
        include_only = {}

        def insert_with_parents(pk):
            if pk not in include_only:
                loc_type = loc_types_by_pk[pk]
                include_only[pk] = loc_type
                if loc_type.parent_type_id:
                    insert_with_parents(loc_type.parent_type_id)

        # if these types were just created, the user-provided IDs were placeholders
        user_specified = [loc_type_db[lt_id].pk for lt_id in include_only_ids]
        for pk in user_specified:
            insert_with_parents(pk)
        return include_only
def _get_include_only ( include_only_ids , loc_type_db ) : loc_types_by_pk = { lt . pk : lt for lt in loc_type_db . values ( ) } include_only = { } def insert_with_parents ( pk ) : if pk not in include_only : loc_type = loc_types_by_pk [ pk ] include_only [ pk ] = loc_type if loc_type . parent_type_id : insert_with_parents ( loc_type . parent_type_id ) # if these types were just created, the user-provided IDs were placeholders user_specified = [ loc_type_db [ lt_id ] . pk for lt_id in include_only_ids ] for pk in user_specified : insert_with_parents ( pk ) return include_only