What kind of tree is this?

Hello, please tell me what kind of tree this is. It grew up in the country, they thought it was a pear (the leaves are very similar). But then we saw the berries. The berries resemble cherries in appearance, but are almost black in color. It tastes like nothing else, with a bone.

The photo is certainly not very good, take a closer photo to see the leaves, but it looks like a cherry plum, the berries are sour, red-brown in color, closer to black, with an oblong seed in the middle?

Perhaps it is a blackthorn or blackthorn, it grows both in the form of a bush and in the form of a tree, prickly. The fruits, when ripe, are similar in color to plums, and taste sweet and sour, tart, astringent.