def is_parent(G, candiate_parent_id, node_id):
    """Returns true if the candidate_parent_id is a predecessor
    node of the given node_id and false otherwise."""
    predecessors = G.predecessors(node_id)
    parent = next(predecessors, None)
    if parent is None:
        return False
    else:
        return parent == candiate_parent_id