def props_intersection(var_list, new_props_var, carry_vars=None):
    """Perform the intersection of the properties of a list of nodes/edges."""
    if carry_vars is None:
        carry_vars = set(var_list)
    else:
        carry_vars.update(var_list)
    query = '\n//Perform the intersection of the properties of '
    query += ', '.join(var_list) + '\n'
    query += 'WITH [] as {}, '.format(new_props_var) + ', '.join(carry_vars
        ) + '\n'
    var_first = var_list[0]
    query += ('WITH {} + REDUCE(pairs = [], k in keys({}) | \n'.format(
        new_props_var, var_first) +
        """	CASE WHEN ALL(others in [{}] WHERE k in keys(others))
""".
        format(', '.join(var_list[1:])) + '\tTHEN\n' +
        """		pairs + REDUCE(inner_pairs = [], v in {}[k] | 
""".format(
        var_first) +
        '\t\t\tCASE WHEN ALL(others in [{}] WHERE v in others[k])\n'.format
        (', '.join(var_list[1:])) + '\t\t\tTHEN\n' +
        """				inner_pairs + {key: k, value: v}
""" + '\t\t\tELSE\n' +
        '\t\t\t\tinner_pairs\n' + '\t\t\tEND)\n' + '\tELSE\n' +
        '\t\tpairs\n' + '\tEND) as {}, '.format(new_props_var) + ', '.join(
        carry_vars) + '\n')
    query += ("WITH apoc.map.groupByMulti({}, 'key') as {}, ".format(
        new_props_var, new_props_var) + ', '.join(carry_vars) + '\n' +
        """WITH apoc.map.fromValues(REDUCE(pairs=[], k in keys({}) | 
""".
        format(new_props_var) +
        '\tpairs + [k, REDUCE(values=[], v in {}[k] | \n'.format(
        new_props_var) +
        '\t\tvalues + CASE WHEN v.value IN values THEN [] ELSE v.value END)])) as {}, '
        .format(new_props_var) + ', '.join(carry_vars) + '\n')
    carry_vars.add(new_props_var)
    return query
