code: public static boolean isAncestor(IBasicScope from, IBasicScope ancestor) {
          IBasicScope current = from;
          while (current.hasParent()) {
              current = current.getParent();
              if (current.equals(ancestor)) {
                  return true;
              }
          }
          return false;
      }
docs: Check whether one scope is an ancestor of another
  
  @param from
  Scope
  @param ancestor
  Scope to check
  @return <pre>
  true
  </pre>
  
  if ancestor scope is really an ancestor of scope passed as from parameter,
  
  <pre>
  false
  </pre>
  
  otherwise.