public function node($ref)
    {
        $type = $this->alias();
        $table = $this->table();
        $path = [];

        if (is_array($ref)) {
            $path = implode('/', array_values(array_filter($ref)));
            $path = explode('/', $path);
        } elseif (is_string($ref)) {
            $path = explode('/', $ref);
        }

        if (empty($path)) {
            return false;
        }

        $start = $path[0];
        unset($path[0]);

        $queryData = [
            'conditions' => [
                "{$type}.lft" . ' <= ' . "{$type}0.lft",
                "{$type}.rght" . ' >= ' . "{$type}0.rght",
            ],
            'fields' => ['id', 'parent_id', 'alias'],
            'join' => [[
                    'table' => $table,
                    'alias' => "{$type}0",
                    'type' => 'INNER',
                    'conditions' => [
                        "{$type}0.alias_hash" => md5($start),
                        "{$type}0.plugin = {$type}.plugin",
                    ]
            ]],
            'order' => "{$type}.lft" . ' DESC'
        ];

        foreach ($path as $i => $alias) {
            $j = $i - 1;

            $queryData['join'][] = [
                'table' => $table,
                'alias' => "{$type}{$i}",
                'type' => 'INNER',
                'conditions' => [
                    "{$type}{$i}.lft" . ' > ' . "{$type}{$j}.lft",
                    "{$type}{$i}.rght" . ' < ' . "{$type}{$j}.rght",
                    "{$type}{$i}.alias_hash" => md5($alias),
                    "{$type}{$i}.plugin = {$type}{$i}.plugin",
                    "{$type}{$j}.id" . ' = ' . "{$type}{$i}.parent_id"
                ]
            ];

            $queryData['conditions'] = [
                'OR' => [
                    "{$type}.lft" . ' <= ' . "{$type}0.lft" . ' AND ' . "{$type}.rght" . ' >= ' . "{$type}0.rght",
                    "{$type}.lft" . ' <= ' . "{$type}{$i}.lft" . ' AND ' . "{$type}.rght" . ' >= ' . "{$type}{$i}.rght"
                ]
            ];
        }
        $query = $this->find('all', $queryData);
        $result = $query->toArray();
        $path = array_values($path);
        if (!isset($result[0]) ||
            (!empty($path) && $result[0]->alias !== $path[count($path) - 1]) ||
            (empty($path) && $result[0]->alias !== $start)
        ) {
            return false;
        }

        return $query;
    }