function getFunctionParent(path) {
  return (path.scope.getFunctionParent() || path.scope.getProgramParent()).path;
}
Babel-7 returns null if there is no function parent
and uses getProgramParent to get Program