{php} if(!empty($obj['childids'])){ $parent_obj=$obj; }elseif(!empty($obj['parent'])){ $parent_obj=$obj['parent']; } {/php}