Get Filter options of Layered Navigation

Hi! so the thing is i’ve been trying to fetch filters(layered navigation) list that displays on storefront as well. I am getting the filters right, like if on frontend 3 filter options are avialable(color,size,category) i’m getting it, butif i traverse $filter->getItems(), it’ll give me ALL the options, like if there are 100 color in the backend it’ll return all of them, but i need only those options which display on layered navigation on storefront(i.e only those which have saleble products) like if there are only 3 colors available that have saleble products i want my custom code to return me only those 3 colors without looping through whole product collection. For the life of me i couldn’t figure out how magento handles it on storefront. I need some urgent help with this situation. Thanks in advance!
P.S: using magento 2.3.2 on linux

submitted by /u/Thejokeyboy123
[link] [comments]