if (x >> 22)
checks if any bit higher than 21th is set. I have no clue why you shift by 22 (looks like an arbitrary number - why the heck do you do it this way?). If you want to check if an entry is present (in a paging structure of any level), check bit 0 of that entry. Note that checking the highest bits would only work if the entry was assigned with high address (wouldn't catch, say, 0x100000).
Also note that if present
bit is 0, all the other bytes are ignored, hence the OS can store any values in them, which might also be an information that will come handy one day.