Return all folder IDs of a folder tree, starting at $folderId, up to a depth of $depth

@param  int|int[] $folderId the folder id or an array of folder ids
@param  int $depth max tree traversal depth
@return int[]
@since 2.3
764534
public static function getFolderTreeIds($folderId, $depth = 1)
    {
        $result = \is_array($folderId) ? $folderId : [ $folderId ];

        if ($depth > 1) {
            $folders = self::create()
                ->filterByParent($folderId, Criteria::IN)
                ->withColumn('id')
                ->find();

            foreach ($folders as $folder) {
                $result = array_merge(
                    $result,
                    self::getFolderTreeIds($folder->getId(), $depth - 1)
                );
            }
        }

        return $result;
    }
380662
protected function arrayDepth($element, $depth = 1) {
        if (is_array($element)) {
            $maxDepth = $depth;
            foreach($element as $el) {
                $d = $this->arrayDepth($el, $depth + 1);
                if ($d > $maxDepth) {
                    $maxDepth = $d;
                }
            }
            return $maxDepth;
        } else {
            return $depth;
        }
    }
242953
public static function getChildPageIds($pageId)
    {
        if (empty(self::$preloaded_page_children)) {
            foreach (static::preloadArray() as $key => $page) {
                if (!isset(self::$preloaded_page_children[$page->parent])) {
                    self::$preloaded_page_children[$page->parent] = [];
                }
                self::$preloaded_page_children[$page->parent][] = $page->id;
            }
        }
        return !empty(self::$preloaded_page_children[$pageId]) ? self::$preloaded_page_children[$pageId] : [];
    }
902045
public function delete($folderId, $childId, $optParams = array()) {
      $params = array('folderId' => $folderId, 'childId' => $childId);
      $params = array_merge($params, $optParams);
      $data = $this->__call('delete', array($params));
      return $data;
    }
25295
public function getAccountChildrenIds($id)
  {
    $ids = array();

    $this->Account->byParent($id)->each(function($Account) use (&$ids)
    {
      if($Account->is_group)
      {
        $ids = array_merge($ids, $this->getAccountChildrenIds($Account->id));
      }

      array_push($ids, $Account->id);
    });

    return $ids;
  }
1026549
public function findAll($id)
    {
        $result = array();
        $root = $this->findById($id);

        if ($root !== false) {
            $result = array_merge($result, array($root));
        }

        return array_merge($result, $this->findParentNodesByChildId($id));
    }
495077
public function get_slots_in_section($sectionid) {
        $slots = array();
        foreach ($this->slotsinorder as $slot) {
            if ($slot->section->id == $sectionid) {
                $slots[] = $slot->slot;
            }
        }
        return $slots;
    }
1078516
private function getFolderById(int $folderId): \stdClass
    {
        $folder = Craft::$app->assets->getFolderById($folderId);
        if ($folder) {
            $volume = $folder->getVolume();
            return  (object) [
                'id' => $folderId,
                'handle' => $volume->handle
            ];
        }
        return null;
    }
746086
private function getPermissions($items = null, $depth = 0)
    {
        $permissions = array();

        if ($items === null) {
            $items = $this->owner->getAuthItems();
        }

        foreach ($items as $itemName => $item) {
            $permissions[$itemName] = array(
                'name' => $itemName,
                'item' => $item,
                'children' => $this->getPermissions($item, $depth + 1),
                'depth' => $depth,
            );
        }

        return $permissions;
    }
1344361
public static function parentID($menuLinkID)
    {
        $parentIDs = [];
        while($menuLinkID != null){
            $parentObj = MenuLink::all()->where('menuLinkID', $menuLinkID)->first();
            if ($parentObj) {
                $menuLinkID = $parentObj->parent;
                if ($menuLinkID) {
                    $parentIDs[] = $menuLinkID;
                }
            }
            if ($parentObj || !$menuLinkID) {
                $menuLinkID = null;
            }
        }
        return $parentIDs;
    }
203669
public function findByFileId($fileId)
    {
        foreach ($this->volumes as $volume) {
            try {
                $file = $volume->findFile($fileId);
                if ($file) {
                    return $volume;
                }
            } catch (\Exception $e) {
            }
        }

        return null;
    }
250704
public function create_folder($foldername, $parentid = 0) {
        $params = array('name' => $foldername, 'parent' => array('id' => (string) $parentid));
        $this->reset_state();
        $result = $this->post($this->make_url("/folders"), json_encode($params));
        $result = json_decode($result);
        return $result;
    }
1014224
public function getChildren($parentID)
    {
        $tmp = [];
        foreach($this->categoryList as $key => $item){
            if($item->parentID == $parentID) {
                $tmp[] = $item;
            }
        }

        return $tmp;
    }
683923
protected function listCalcDepth($pageUid, array $rootLineRaw, $depth = null)
    {
        if ($depth === null) {
            $depth = 1;
        }

        if (empty($rootLineRaw[$pageUid])) {
            // found root page
            return $depth;
        }

        // we must be at least in the first depth
        ++$depth;

        $pagePid = $rootLineRaw[$pageUid];

        if (!empty($pagePid)) {
            // recursive
            $depth = $this->listCalcDepth($pagePid, $rootLineRaw, $depth);
        }

        return $depth;
    }
609981
public function getRoot($categoryId)
    {
        $category = CategoryQuery::create()->findPk($categoryId);

        if (0 !== $category->getParent()) {
            $parentCategory = CategoryQuery::create()->findPk($category->getParent());

            if (null !== $parentCategory) {
                $categoryId = $this->getRoot($parentCategory->getId());
            }
        }

        return $categoryId;
    }
790034
private function keyPath($cacheId)
    {
        $cacheId = $this->normalizeKey($cacheId);

        return FileUtils::join(array($this->root, $this->spread($cacheId)));
    }
641259
public static function view_folder($folderid) {
        global $DB, $CFG;
        require_once($CFG->dirroot . "/mod/folder/lib.php");

        $params = self::validate_parameters(self::view_folder_parameters(),
                                            array(
                                                'folderid' => $folderid
                                            ));
        $warnings = array();

        // Request and permission validation.
        $folder = $DB->get_record('folder', array('id' => $params['folderid']), '*', MUST_EXIST);
        list($course, $cm) = get_course_and_cm_from_instance($folder, 'folder');

        $context = context_module::instance($cm->id);
        self::validate_context($context);

        require_capability('mod/folder:view', $context);

        // Call the page/lib API.
        folder_view($folder, $course, $cm, $context);

        $result = array();
        $result['status'] = true;
        $result['warnings'] = $warnings;
        return $result;
    }