moved tree logic into filters