How to properly remove (delete all related files and folders) ESA SNAP product from Python?

I wrote a small piece of Python code for removing ESA SNAP products:

import shutil, os

def removeProduct(file_path):
	# Very ugly way of deleting ESA SNAP product. It was tested only with "BEAM-DIMAP" and "GeoTIFF" formats.
	if (os.path.exists(file_path)):
		if (os.path.splitext(file_path)[1] == '.dim'):
			dirToRem = get_data_path(file_path)
			shutil.rmtree(dirToRem) # will delete a directory and all its contents.
		print("Trying to remove non-existing file: {0}".format(file_path)])

def get_data_path(file_path):
	# Gets '.data' folder for '.dim' files (products saved in "BEAM-DIMAP" format)
	data_path = os.path.splitext(file_path)[0] + '.data'
	if (not os.path.isdir(data_path)):
		print("There is *NO* following folder '{0}'. Please ensure where data for '{1}' file are".format(data_path, file_path))
	return data_path

I wonder if there is any ready-to-use method in snappy module for removing geospatial data sets ? Could you suggest proper way of removing (from Python) ESA SNAP products saved in any format, please?

With out reading the product there is no generic way.
To improve the deletion you can have a look at the following code snippet:

When reading the product you also have the reader (casted to AbstractProductReader).
The AbstractProductReader has the method getProductComponents().
This returns the components which belong to the product.
But I think the above example is appropriate for you.