Programmatically get all work item children

Hi all,
I would programmatically find all children of work item and, after, analyze the custom attribute of these.
I try in this way:
but I obtain this error:
Any suggestions?
Thanks
Andrea
I would programmatically find all children of work item and, after, analyze the custom attribute of these.
I try in this way:
IWorkItemReferences referencesCopy = wis.resolveWorkItemReferences(wiCopy, null);
List<IReference> links = referencesCopy.getReferences(WorkItemEndPoints.CHILD_WORK_ITEMS);
for (IReference lin : links) {
List<IAttributeHandle> childsWorkItem = ((IWorkItem)lin.getLink().getWorkingCopy()).getCustomAttributes();
for ( IAttributeHandle iah : childsWorkItem) {
IAttribute customAttribute = (IAttribute) (repositoryItemService.fetchItem(iah, null));
if (customAttribute.getIdentifier().equalsIgnoreCase("defectalreadyopened"))
{
.....
}
}
}
but I obtain this error:
java.lang.ClassCastException: com.ibm.team.links.internal.links.impl.AuditableLinkImpl incompatible with com.ibm.team.workitem.common.model.IWorkItem
Any suggestions?
Thanks
Andrea