def _get_object(g, s, p):
    """
    Retrieve the (first) object of a relation. This is mainly to be used where
    we expect only one relation of the specified type.

    Parameters
    ----------
    g : rdflib.Graph
    s : rdflib.term.URIRef
        The subject of the relation.
    p : rdflib.term.URIRef
        The predicate of the relation.

    Returns
    -------
    rdflib.term.URIRef
    """
    try:
        return list(g.objects(s, p))[0]
    except IndexError:
        return None
