I would recommend that you store a value that counts the number of times it appears in your pedigree. Storing the value rather than calculating it would keep things quick in your database.
Maybe run a schedule script that daily does a "replace field contents" on a "livestock::pedigreeCount" field. If you have a foreign key field relating a specific livestock record to it's parents as a return delimited list, then your calc would look something like this:
ExecuteSQL("SELECT COUNT(*) FROM livestock WHERE FK_yourForeignKey LIKE ?" ; "" ; "" ; "%" & livestock::PrimaryKey & "%" )
Then it's just a simple matter of conditional formatting to get the colors you want above based on the stored number.
many thanks, I think I can get my head around this, thanks particularly for the ExecuteSQL suggestion