def pdfrompl(pl, trim=True):
    """
    This function takes a list of paths and returns a path dictionary
    (two-level by source and destination node).

    :param pl: List of paths
    :param trim: Eliminate full loops (True by default)
    :return: path dictionary
    """
    pd = dict()
    for path in pl:
        src = path[0]
        dst = path[-1]
        if not trim or src != dst:
            pd.setdefault(src, dict())[dst] = path
    return pd