Deep nesting of conditionals can make things tricky to follow at a glance. When you have code like this it's generally a prime target for refactoring into separate helper methods to break things up a bit.