use range to recursively check all levels, O(n)