refactored location picker tree function