move leafify_stack back to btreemap