This nested conditional is kind of gross, but I honestly can't think of a much better way to do it.  It might make sense to refactor a few of the tests into private methods that are descriptive, like "isAnInstanceVariable" and the like, to avoid hard-to-parse getParentPath().getLeaf() chains inside all the boolean propositions.