$childrenAware =
$reference->
isChildrenAware();
// first level of parent-child tree?
if ($childrenAware &&
$reference !==
$definition) { // where product.children.parentId IS NULL
$nested->
addFilter(new EqualsFilter($reference->
getEntityName() . '.parentId', null
));
} if ($cascade instanceof ChildrenAssociationField
) { // break endless loop
if ($childCounter >= 30 || !
$cloneChildren) { $criteria->
removeAssociation($cascade->
getPropertyName());
continue;
} ++
$childCounter;
$this->
addCloneAssociations($reference,
$nested,
$cloneChildren,
$childCounter);
continue;
} $this->
addCloneAssociations($reference,
$nested,
$cloneChildren);
}