code: function(data) {
              var count, obj, result = [], item, iterateItem;
              if(!data || typeof data === 'string') {
                  return null; 
              }
  
              if($.isArray(data)) { //array
                  /* 
                     function to iterate inside item of array if item is object.
                     Caclulates count of keys in item and store in obj. 
                  */
                  iterateItem = function (k, v) {
                      obj = {value: k, text: v};
                      if(count++ >= 2) {
                          return false;// exit from `each` if item has more than one key.
                      }
                  };
              
                  for(var i = 0; i < data.length; i++) {
                      item = data[i]; 
                      if(typeof item === 'object') {
                          count = 0; //count of keys inside item
                          $.each(item, iterateItem);
                          //case: [{val1: 'text1'}, {val2: 'text2} ...]
                          if(count === 1) { 
                              result.push(obj); 
                              //case: [{value: 1, text: 'text1'}, {value: 2, text: 'text2'}, ...]
                          } else if(count > 1) {
                              //removed check of existance: item.hasOwnProperty('value') && item.hasOwnProperty('text')
                              if(item.children) {
                                  item.children = this.makeArray(item.children);   
                              }
                              result.push(item);
                          }
                      } else {
                          //case: ['text1', 'text2' ...]
                          result.push({value: item, text: item}); 
                      }
                  }
              } else {  //case: {val1: 'text1', val2: 'text2, ...}
                  $.each(data, function (k, v) {
                      result.push({value: k, text: v});
                  });  
              }
              return result;
          }
docs: convert data to array suitable for sourceData, e.g. [{value: 1, text: 'abc'}, {...}]