/*var json_src = {
  "path": "./test_folder",
  "name": "test_folder",
  "type": "folder",
  "children": [
    {
      "path": "./test_folder/folder_1",
      "name": "folder_1",
      "type": "folder",
      "children": [
        {
          "path": "./test_folder/folder_1/file1.mkv",
          "name": "file1.mkv",
          "type": "file"
        }
      ]
    },
    {
      "path": "./test_folder/folder_2",
      "name": "folder_2",
      "type": "folder",
      "children": [
        {
          "path": "./test_folder/folder_2/file1.mkv",
          "name": "file1.mkv",
          "type": "file"
        },
        {
          "path": "./test_folder/folder_2/file2.mkv",
          "name": "file2.mkv",
          "type": "file"
        }
      ]
    }
  ]
};
*/
var json_src ="";
var Client = require('node-rest-client').Client;
var client = new Client();
var list_files = [];
// direct way
/*client.get("http://anax.feralhosting.com:8088/files", function (data, response) {
    // parsed response body as js object
    //var json_src = data;
    console.log(data);
    // raw response
    //console.log(response);
});*/

// registering remote methods
client.registerMethod("jsonMethod", "http://anax.feralhosting.com:8088/files", "GET");

client.methods.jsonMethod(function (data, response) {
    // parsed response body as js object
    console.log(data);
    var json_src = data;
    list_files = []
    // raw response
    //console.log(response);
    findFilesRecursively(json_src);
    console.log(list_files);
});


function findFilesRecursively(json){
    if(json.type == "file"){
      list_files.push(json.path);
    }
    else {
      for (var i = 0; i < json.children.length; i++) {
        var child = json.children[i];
        findFilesRecursively(child);
      }
    }
}

@@ -766,29 +766,11 @@
 %0A*/%0A
-var json_src =%22%22;%0Avar
+let
  Cli
@@ -811,19 +811,19 @@
 Client;%0A
-var
+let
  client 
@@ -838,19 +838,19 @@
 ient();%0A
-var
+let
  list_fi
@@ -1248,25 +1248,16 @@
 nMethod(
-function 
 (data, r
@@ -1256,32 +1256,35 @@
 (data, response)
+ =%3E
  %7B%0A    // parsed
@@ -1338,33 +1338,8 @@
 a);%0A
-    var json_src = data;%0A
     
@@ -1428,24 +1428,20 @@
 rsively(
-json_src
+data
 );%0A    c
@@ -1470,24 +1470,19 @@
 ;%0A%7D);%0A%0A%0A
-function
+let
  findFil
@@ -1498,14 +1498,20 @@
 vely
+ = 
 (json)
+ =%3E
 %7B%0A  
@@ -1651,19 +1651,19 @@
         
-var
+let
  child =

add es2015 feature because why not use node 7.1.0