Fix nonbinary apetree with test