Fry the onion in the oil until lightly golden.
Season the potatoes with salt and pepper to taste, add the onions and cheese if you're using it, and mix well.
Set aside.
Preheat the oven to 400 degrees.
Line a baking sheet with parchment paper.
Roll the puff pastry quite thinly, about 1/4 inch or less, and cut into 6 equal squares.
Divide the filling into 6 parts.
Place one portion in the middle of a square and fold into a triangle.
Press hard on the sides to seal well and brush with the egg yolk.
Repeat with the remaining dough and filling.
Sprinkle the borekas with sesame seeds.
Bake on the middle shelf of the preheated oven for 25 minutes, or until crisp and golden.
Check the bottoms to see if they are done they should be brown.
Serve warm or at room temperature.
Ready in 1 hour.