moved all code from fptree_query_utils to this module [ci skip]