fix for getParent function

incorrect calculate parents for more nested levels