private static function placeInExpanded($data, array &$nodes, array $expansion_data, $name_property = 'name', $children_property = 'children', $output_type = 'keep_type') { $keys = array_keys($expansion_data); $column = $keys[0]; $data_to_store = array_shift($expansion_data); $found_node = null; foreach ($nodes as $node) { if (Generic::get($node, $name_property) == Generic::get($data, $column)) { $found_node = $node; } } if ($found_node == null) { $found_node = array(); $found_node[$name_property] = Generic::get($data, $column); foreach ($data_to_store as $col) { $found_node[$col] = Generic::get($data, $col); } if (count($expansion_data)) { $found_node[$children_property] = array(); } if ($output_type == 'object') { $found_node = (object) $found_node; } $nodes[] = $found_node; } if (count($expansion_data)) { Arrays::placeInExpanded($data, Generic::get($found_node, $children_property), $expansion_data, $name_property, $children_property, $output_type); } }