BTW, that code would be pretty time-consuming on a large database. Rather than computing all relationships between all people and all of their associations, it probably would be better to only do the selected person.
[I doubt an AI would suggest the reduced scope, which is why we still need humans (for now).]