parent; while ( null !== $instance && $count++ < self::MAX_ANCESTORY_DEPTH ) { $results[] = $instance; $instance = $instance->parent; } return array_reverse($results); } /** @return self[] */ public function getAncestorsAndSelf(): array { $results = $this->getAncestors(); $results[] = $this; return $results; } }