def props_intersection_from_list(list_var, new_props_var, carry_vars=None):
    """Perform the intersection of the properties of a neo4j list of nodes/edges."""
    if carry_vars is None:
        carry_vars = set([list_var])
    else:
        carry_vars.add(list_var)
    query = '\n//Perform the intersection of the properties of {}'.format(
        list_var) + '\n'
    query += 'WITH [] as {}, '.format(new_props_var) + ', '.join(carry_vars
        ) + '\n'
    query += ('WITH {} + REDUCE(pairs = [], k in keys({}[0]) | pairs +\n'.
        format(new_props_var, list_var) +
        """	CASE WHEN ALL(other in {} WHERE k in keys(other))
""".format(
        list_var) + '\tTHEN\n' +
        '\t\tREDUCE(inner_pairs = [], v in {}[0][k] | inner_pairs +\n'.
        format(list_var) +
        """			CASE WHEN ALL(other in {} WHERE v in other[k])
""".format(
        list_var) + '\t\t\tTHEN\n' + '\t\t\t\t{key: k, value: v}\n' +
        '\t\t\tELSE\n' + '\t\t\t\t[]\n' + '\t\t\tEND)\n' + '\tELSE\n' +
        '\t\t[]\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
