protected static function detectLoop($parentID, $childID, $vid)
    {
        if ($childID === $parentID) {
            return true;
        }

        foreach (static::getChildren($childID, $vid) as $grandchild) {
            if (static::detectLoop($parentID, $grandchild, $vid)) {
                return true;
            }
        }

        return false;
    }