I'd reverse this and `return None` early, it saves you an indent level for a dozen or so lines.