def get_first_end(pipes_selection):
    """
    Find an end node of one of the pipelines to build with the pipes from
    *pipes_selection*.

    Look for a node which occurs only once amongst the ends of the pipes of
    *pipes_selection*. If this node is match to the label 'A' ('B') *reverse* is
    set to True (False).

    Parameters
    ----------
    pipes_selection:
        Dataframe of the selected pipes (same load as the first pipe).

    Returns
    -------
    int
        Index of the dataframe *pipes_selection* referring to the end node.
    bool
        True (False) if the node is at the 'A' ('B') end.
    """
    points = list(pipes_selection['pB']) + list(pipes_selection['pA'])
    for idx, pipe in pipes_selection.iterrows():
        countA, countB = 0, 0
        for point in points:
            if point == pipe['pA']:
                countA += 1
            if point == pipe['pB']:
                countB += 1
        if countA == 1:
            reverse = False
            break
        if countB == 1:
            reverse = True
            break
    return idx, reverse
