def find_target_container(portal_type, record):
portal_type = portal_type or record.get("<STR_LIT>")<EOL>container = get_container_for(portal_type)<EOL>if container:<EOL><INDENT>return container<EOL><DEDENT>parent_uid = record.pop("<STR_LIT>", None)<EOL>parent_path = record.pop("<STR_LIT>", None)<EOL>target = None<EOL>if parent_uid:<EOL><INDENT>target = get_object_by_uid(parent_uid)<EOL><DEDENT>elif parent_path:<EOL><INDENT>target = get_object_by_path(parent_path)<EOL><DEDENT>else:<EOL><INDENT>fail(<NUM_LIT>, "<STR_LIT>")<EOL><DEDENT>if not target:<EOL><INDENT>fail(<NUM_LIT>, "<STR_LIT>")<EOL><DEDENT>return target<EOL>
Locates a target container for the given portal_type and record

    :param record: The dictionary representation of a content object
    :type record: dict
    :returns: folder which contains the object
    :rtype: object