You could make an Ajax call to populate an object with the full tree hierarchy, then reference that object in your tree config. Your REST web resource obviously needs to return a JSON object representing your tree in the correct format (example below).
//populate this with results from Ajax call
var rootNode = {
text : 'Root Node',
expanded : true,
children : [
{
text : 'Child 1',
leaf : true
},
{
text : 'Child 2',
leaf : true
},
{
text : 'Child 3',
children : [
{
text : 'Grand Child 1',
children : [
{
text : 'Etc',
leaf : true
}
]
}
]
}
]
}
var tree = {
xtype : 'treepanel',
id : 'treepanel',
autoScroll : true,
root : rootNode
}