function linkList = depthCheck(linkList)

listSize = size(linkList,1)+1;

linkList = cat(2,linkList, zeros(size(linkList,1),1));
currentRow = size(linkList,1);
r = [0;0];
% depth = 1;

linkList(currentRow,end) = 1;
% depth = depth + 1;
%%
while (~isempty(currentRow))
    row = currentRow(1);
    for i = 1:2
        r(i) = linkList(row,i);
        if(r(i) > listSize)
            r(i) = linkList(row,i) - listSize;
            linkList(r(i),end) = linkList(currentRow(1),end)+1;
            currentRow = [currentRow; r(i)];
        end
    end
    currentRow = currentRow(2:end);
end
end



% linkList = aglomCluster(data);
% listSize = size(data,1);
% 
% % linkList(:,4) = 0;
% featureList = cell(listSize-1,1);
% currentRow = [2*listSize-1];
% 
% %%
% while (~isempty(currentRow))
%     if(currentRow(1) > listSize) 
%         row = currentRow(1) - listSize
%         classList = traceLinkageToBinary(linkList, row);
%         featureList{row} = rfFeatureSelection(data(classList>0,:), classList(classList>0));
%         currentRow = [currentRow(2:end); linkList(row,1); linkList(row,2)];
%     else
%         currentRow = currentRow(2:end);
%     end
% end
% 
% end