For this function please check the OSM obj info plugin: https://github.com/Rub21/osm-obj-info