protected function checkForCycle(Pap_Affiliates_User $potentialParent, $userId) { $tree = new Pap_Common_UserTree(); $tree->startCheckingLoops(); $affiliate = $potentialParent; while ($affiliate != null){ if ($userId == $affiliate->getId()) { return false; } $affiliate = $tree->getParent($affiliate); } return true; }