Use a simpler model (using ancestors for graphs only, not for triples).
Centralize in LietralTriple and NonLiteralTriple
Complete, untested implementation