"recursive" checker for validity