private function include_replies_for($comments) { $parent = array(); foreach ($comments as $each_comment) { $parent[] = $each_comment; $children = Comment::child_comments($each_comment->id); if (count($children) > 0) { $children_with_replies = $this->include_replies_for($children); $parent = array_merge($parent, $children_with_replies); } } return $parent; }