SELECT DISTINCT ?term
WHERE {
  { ?s1 ?p1 ?term . }
  UNION
  { ?term ?p2 ?o2 . }
  FILTER(isIRI(?term) && (STRSTARTS(str(?term), "http://purl.obolibrary.org/obo/UPHENO_") || STRSTARTS(str(?term), "http://purl.obolibrary.org/obo/UPHENO_")))
}
