src/Leevel/Tree/Tree.php
public function getParent($id, bool $withItSelf = false): array
    {
        if (!array_key_exists($id, $this->map)) {
            return [];
        }

        $data = [];

        if (array_key_exists($this->map[$id], $this->map)) {
            $data[] = $this->map[$id];
        }

        if (true === $withItSelf) {
            $data[] = $id;
        }

        return $data;
    }
public function getParent($id, bool $withItSelf = false): array
    {
        if (!array_key_exists($id, $this->map)) {
            return [];
        }

        $data = [];

        if (array_key_exists($this->map[$id], $this->map)) {
            $data[] = $this->map[$id];
        }

        if (true === $withItSelf) {
            $data[] = $id;
        }

        return $data;
    }
取得给定 ID 上级父级 ID.

@param int|string $id
@param bool       $withItSelf

@return array