It's most likely ill-advised to create such an array as it will denormalize the relationship between Contact and PolicyPeriod, which already exists. This will not only represent duplicative data in the database, it will have the problem of requiring maintenance, and possibly getting out of synch with the existing relationship present in the database.
A virtual property is likely a better solution to this problem, as it doesn't possibly introduce database inconsistencies and doesn't denormalize the database further.
I'm assuming the requirement to return PolicyPeriods rather than Policies as these are the typical unit-of-work for Policy transactions, and the entity which contains Policy Number, but if this isn't what you're after, you'd just replace elt.Branch with elt.Branch.Policy, and change the return type and name of the virtual property.
package com.acme.enhancements
uses gw.api.database.Query
uses gw.api.database.Relop
enhancement PersonEnhancement : entity.Person {
property get PolicyPeriods() : Set<PolicyPeriod> {
var policiesImPresentOn = Query.make(PolicyContactRole).compare(PolicyContactRole#ContactDenorm, Relop.Equals,this).select().toList()
var setToReturn = new HashSet<PolicyPeriod>()
policiesImPresentOn.each(\elt -> setToReturn.add(elt.Branch))
return setToReturn
}
}