Create renderable nested tree array like Menu Tree or Taxonomy Tree I am getting a nested array with children property from the WebSerice. I want to create the render able array so that I can use "drupal_render" function to render final HTML. I looked at the 'menu_tree_output' and 'taxonomy tree" that Drupal generates, but there is not proper documentation that mention how to structure the array to make it render able nested list. 

Lets make it short: How do I restructure the final array that I get from Webservice so that I can make it renderable using drupal_render api. Final output is nested list(Folder tree).
What you are trying to solve is a recursive problem.... See below code which solves problem..

function listArrayRecursive($array_name, $ident = 0){
  if (is_array($array_name)){
    foreach ($array_name as $k =&gt; $v){
      if (is_array($v)){
        for ($i=0; $i &lt; $ident * 10; $i++){ echo "&amp;nbsp;"; }
        echo $k . " : " . "&lt;br&gt;";
        listArrayRecursive($v, $ident + 1);
      }else{
        for ($i=0; $i &lt; $ident * 10; $i++){ echo "&amp;nbsp;"; }
        echo $k . " : " . $v . "&lt;br&gt;";
      }
    }
  }else{
    echo "Variable = " . $array_name;
  }
}

$ages = array(
        "ahmed" =&gt; "25",
        "mohamed" =&gt; "35",
        "group" =&gt; array("omar" =&gt; "15", "abdalla" =&gt; "20", "sub group" =&gt; array("john" =&gt; "10", "peter" =&gt; "20")));

listArrayRecursive($ages);


Output will be