Working with Tree and Contain

This is probably an easy one for someone out there. I’m just having trouble getting it all put together. I’m trying to pull tree data with assoicated data that also has tree structure.

        $navigation = $this->find('children', [
            'for' => $id
        ])
        ->find('threaded')
        ->contain(['Links'])
        ->toArray()
        ;

Links has Tree behavior as well and I need it to be sorted by the lft column.

Just as an example I did this in CakePHP2 like so:

        $navigation = $this->find('threaded', array(
            'conditions' => array(
                'Menu.lft BETWEEN ? AND ?' => array($menu['Menu']['lft'], $menu['Menu']['rght'])
            ),
            'order' => 'lft',
            'contain' => array('Link' => array(
                'order' => 'lft'
            ))
        ));

To add to the query that’s run for the contained table, look at the queryBuilder option. There are a few usage examples on that page, including one about order.