function x = stuff(e, x)
if nargin == 1
  x = {{0,3,{0,5,0}},7,{{{0,9,0},11,0},13,{0,15,0}}};
end

plist(x)
fprintf('\n')
l = x{1};
v = x{2};
r = x{3};

if e == v
   fprintf('found the %d!\n', e);
   return
end

if e < v
   fprintf('%d is smaller than %d, looking left!\n', e, v);
   if iscell(l)
      x = {stuff(e, l), v, r};
   else
      fprintf('%d not found, inserting it!\n', e);
      x = {{0,e,0}, v, r};
   end
else
   fprintf('%d is larger than %d, looking right!\n', e, v);
   if iscell(r)
      x = {l, v, stuff(e, r)};
   else
      fprintf('%d not found, inserting it!\n', e);
      x = {l, v, {0,e,0}};
   end
end

function plist(x)
if iscell(x{1})
   plist(x{1})
end

fprintf('%d ', x{2})

if iscell(x{3})
   plist(x{3})
end
