Pascal has the solution for that. Nested functions:
procedure foobar;
procedure helper1;
begin
end;
procedure helper2;
procedure subhelper2;
begin
end;
begin
end;
procedure helper3;
begin
end;
begin
end;Only the foobar function can access the helper functions.