private function collectTagsByChild(Tag $tag, $list) { $list[] = $tag; foreach ($tag->getChildren() as $child) { $list = $this->collectTagsByChild($child, $list); } return $list; }