def element_junction_tuples(junction_elements=True, branch_elements=True, res_elements=False):
    """
    Utility function
    Provides the tuples of elements and corresponding columns for junctions they are connected to
    :param junction_elements: whether tuples for junction elements e.g. sink, source,
    ... are included
    :param branch_elements: whether branch elements e.g. pipe, pumps, ... are included
    :return: set of tuples with element names and column names
    """
    ejts = set()
    if junction_elements:
        elements = ["sink", "source", "ext_grid"]
        for elm in elements:
            ejts.update([(elm, "junction")])
    if branch_elements:
        elements = ["pipe", "valve", "pump", "circ_pump_mass", "circ_pump_pressure",
                    "heat_exchanger"]
        for elm in elements:
            ejts.update([(elm, "from_junction"), (elm, "to_junction")])
    if res_elements:
        elements_without_res = ["valve"]
        ejts.update(
            [("res_" + ejt[0], ejt[1]) for ejt in ejts if ejt[0] not in elements_without_res])
    return ejts