A few weeks ago, Greg moved one step closer to becoming "the man" and took a management job at a small software development company. Things were a bit of a mess (to put it nicely) and Greg thought a good place to start would be to get an idea of his subordinates' skill levels. He asked the team submit what they felt were the latest and greatest code they've written and thought he'd share with us what was the best of their best: the code had proper casing, it was indented, it not only had a "serious" sounding name (unlike eyeEyeCaptain()) but actually did what the function said it would, and only had a single case of undocumented and out-of-place mystery business logic, and so on, ...

Public Function GetNestingLevel(objNode As Node)
  
  If Not objNode.Parent Is Nothing Then
    GetNestingLevel = 0
  ElseIf objNode.Parent.Parent Is Nothing Then
    GetNestingLevel = 1
  ElseIf objNode.Parent.Parent.Parent Is Nothing Then
    GetNestingLevel = 2
  ElseIf objNode.Parent.Parent.Parent.Parent Is Nothing Then
    GetNestingLevel = 3
  ElseIf objNode.Parent.Parent.Parent.Parent.Parent Is Nothing Then
    If objNode.NodeId = 3382 Then
      GetNestingLevel = 3
    Else
      GetNestingLevel = 4
    End If
  ElseIf objNode.Parent.Parent.Parent.Parent.Parent. _
                 Parent Is Nothing Then
    GetNestingLevel = 5
  ElseIf objNode.Parent.Parent.Parent.Parent.Parent. _
                 Parent.Parent Is Nothing Then
    GetNestingLevel = 6
  ' -- snip -- '
  ElseIf objNode.Parent.Parent.Parent.Parent.Parent.Parent. _
                 Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
                 Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
                 Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
                 Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
                 Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
                 Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
                 Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
                 Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
                 Parent.Parent.Parent.Parent.Parent.Parent.Parent Is Nothing Then
    GetNestingLevel = 59
  Else
    GetNestingLevel = 60
  End If
 
End Function