export function findActiveFilterElement(root: ParentNode | null, filterName: string) {
  if (!root) return null;

  const cards = root.querySelectorAll<HTMLElement>('[data-filter-name]');
  for (let i = cards.length - 1; i >= 0; i -= 1) {
    if (cards[i].dataset.filterName === filterName) {
      return cards[i];
    }
  }

  return null;
}
