<?php
$haystack = array(
    array("id" => 1,"parent" => 0,"route" => "home","children" => array()),
    array("id" => 2,"parent" => 0,"route" => "news","children" => array()),
    array("id" => 3,"parent" => 0,"route" => "photography","children" => array(
                array("id" => 6,"parent" => 3,"route" => "photography/portraits","children" => array()),
                array("id" => 7,"parent" => 3,"route" => "photography/countries","children" => array()),
                array("id" => 8,"parent" => 3,"route" => "photography/landscapes","children" => array(
                                array("id" => 9,"parent" => 8,"route" => "photography/landscapes/city","children" => array()),
                                array("id" => 10,"parent" => 8,"route" => "photography/landscapes/wilderness","children" => array())
                            )
                )
        )
    ),
    array("id" => 4,"parent" => 0,"route" => "about","children" => array()),
    array("id" => 5,"parent" => 0,"route" => "contact","children" => array()),
);

function recurse($needle = -1, $haystack = NULL){
    static $_tmp = array();

    if (count($_tmp) == 0 && $haystack != NULL && count($haystack) > 0) {
       foreach($haystack as $key => $item) {
          if (count($_tmp) == 0) {
           echo $needle ." === ". $item["id"] . "<br/>\n";

           if((string)$item["id"] === (string)$needle){
               echo "Found: " . $needle . "<br/>\n";
               $_tmp = $item;
               //break;
               return $_tmp;
           } elseif (!empty($item["children"])) {
               echo "calling ". $item["id"]. ".children <br/>\n";
               $_tmp = recurse($needle, $item["children"]);
           }
           }
       }
    }
    return $_tmp;
}

$test = recurse(9, $haystack);
print_r($test);

?>