title: How to get root node in MEL Script?
body: <p>I have come across an existing piece of code that does this, but I assume there must be a better way. So, I need to get a highest level in mesh node in Autodesk Maya.</p>
  
  <pre><code>// List all mesh objects
  string $nodess[] = `ls -type mesh` ;
  
  // Replace existing items on active list with this
  select -r $nodess[0] ;   
  
  int $i = 1 ;
  
  while ($i &lt; 30) {
      // Pick up the tree 30 times
      pickWalk -d up ;
      $i++ ;
  }
  
  // List all selected objects
  string $rootNode[] = `ls -sl` ;
  
  // Clear selection
  select -cl ;
  
  string $myroot = $rootNode[0] ;
  </code></pre>