You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: dendhier.m
    path of file: ./repos/eeglab/functions/miscfunc
    
    the code of the file until where you have to start completion: function [links,topology,node] = dendhier(links,topology,node)
% DENDHIER: Recursive algorithm to find links and distance coordinates on a 
%             dendrogram, given the topology matrix.
%
%     Usage:
    
function as null vector []
%         topology =  dendrogram topology matrix
%         node =      current node; pass as N-1
%

% RE Strauss, 7/13/95 

  n = size(topology,1)+1;             % Number of OTUs

  c1 =   topology(node,1);
  c2 =   topology(node,2);
  clst = topology(node,3);
  dist = topology(node,4);

  if (c1 <= n)
    links = [links; c1 clst 0 dist];
  else                                
    prevnode = find(topology(:,3)==c1);
    prevdist = topology(prevnode,4);
    links = [links; c1 clst prevdist dist];
    [links,topology,node] = dend