public List<TreeNode> parseTree(final String asciiTree) {
        if (asciiTree.isEmpty()) return Collections.emptyList();

        final List<String> lines = Arrays.asList(asciiTree.split(System.lineSeparator()));

        final List<TreeNode> roots = new ArrayList<>();
        final Map<Integer, TreeNode> levelMap = new HashMap<>();

        for (String line : lines) {
            final int level = countLeadingCharacters(line);
            final String value = line.replace("|--", "").trim();

            final TreeNode node = new TreeNode(convertToObject(value));
            if (level == 0) {
                roots.add(node);
            } else {
                levelMap.get(level - 1).addChild(node);
            }
            levelMap.put(level, node);
        }

        return roots;
    }
Parse the tree structure as taken from the Gherkin feature file.
gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/features/StepDefinition.java